Fsniper is a tool to watch for files, and execute commands on them. It can be aquired by anyone running archlinux via these commands


sudo makepkg -i


and that's it. Installed. To start fsniper use the fsniper binary. This will start in the foreground by default, which negligates it's use. Instead of executing it with a "&" appended, we just use the --daemon option. This executes it as, you guessed it, a daemon. Don't execute it yet though, as we have no configuration file

Fsniper uses one configuration file, located in ~/.config/fsniper/config. It  has a very simple structure, but it is a bit littered with curley brackets, so be carefull. Here's the layout:

  watch {

                Directory/you/want/to/watch {

                                 files {

                                       handler = comand you want to execute on file





The files can be defined via name or mime type. The program takes wildcards (* and so on) aswell as enviroment variables. For the handler, "%%" is the full file path, while "%" is just the file name.

  As you can see, it's a simple setup, but hugley usefull. Here is my configuration file:

 watch {

                $HOME/bin {

                                * {

                                               handler = chmod 755 %%



                $HOME {

                                 Desktop {

                                                    handler = rmdir %%




The first one makes every new file in my bin directory executable, and the second one deleats the Desktop folder everytime it is created (kde desktop keeps making one)


I can't see much more to say about fsniper apart from one thing, DON'T use it on file types you are likly to download with firefox (*.tar.gz, *.zip, *. jpg ect, ect,) as they are first put into a *.*.part file, while a seperate *.* file is created, meaning that the *.* file is acted upon, but before it has had any data inputed into it from the *.*.part file.



Subscribe to Comments Feed

Upcoming Linux Foundation Courses

  1. LFD312 Developing Applications For Linux
    05 Jan » 09 Jan - Virtual
  2. LFS220 Linux System Administration
    05 Jan » 08 Jan - Virtual
  3. LFD331 Developing Linux Device Drivers
    12 Jan » 16 Jan - Virtual

View All Upcoming Courses

Who we are ?

The Linux Foundation is a non-profit consortium dedicated to the growth of Linux.

More About the foundation...

Frequent Questions

Join / Linux Training / Board