Run commands when files change
 
 
 
Go to file
Dustin a7e318e684 Add README and license documents 2015-03-07 19:31:24 -06:00
src watchlist,watchedpath: Query file type directly 2015-02-15 00:23:19 -06:00
.gitignore Update .gitignore 2015-03-07 10:32:56 -06:00
COPYING Add README and license documents 2015-03-07 19:31:24 -06:00
Makefile.am First working version 2015-02-01 19:02:47 -06:00
README.md Add README and license documents 2015-03-07 19:31:24 -06:00
configure.ac Initial commit 2015-02-01 19:02:41 -06:00

README.md

onchanged

onchanged is a simple file watcher daemon that executes commands for configured events on the filesystem. It is similar to incron, but aims to be simpler to use and provides additional features.

Configuration

Configuration of onchanged is done through INI-style files that specify paths to watch and commands to run. Example:

[/home/dustin/Sync]
recursive = true
events = created,changed,deleted
action = sync-offlinefiles

This configuration block instructs onchanged to watch the path /home/dustin/Sync and run the command sync-offlinefiles when any event occurs.

By default, configuration files are read from ${XDG_CONFIG_HOME}/onchanged, but alternate paths can be specified on the command line. If a directory is specified, all files within the directory will be read.

The name of each section in a configuration file specifies the path to watch. Valid options within a section are as follows:

  • recursive: If true files in directories below the specified path will be watched as well (default false)
  • events: A comma-separated list of events that will trigger the action. If unspecified, the action will never be triggered. Valid options are:
    • created: A new file was created in the directory
    • changed: An existing file's content or metadata was changed
    • deleted: A file was deleted from the directory
  • action: The command to run when a matching event occurs. The executable must be found using the ${PATH} environment variable. Variable expansion, I/O redirection, etc. will not be performed. Prior to execution, two placeholders will be substituted:
    • $#: The path to the file that triggered the action
    • $%: The event that occurred

Building

To build onchanged from a source distribution, unpack the archive, then use the standard three-step compile/install process:

tar -xJf ./onchanged-0.1.tar.xz
cd onchanged-0.1
./configure
make
sudo make install

You will need to the development files for GLib installed (dev-libs/glib on Gentoo, libglib2-dev on Debian, or glib2-devel on Fedora).

To build from a Git checkout, you will need some additional packages:

  • Vala version 0.20 or later (dev-lang/vala on Gentoo, valac on Debian, vala on Fedora)
  • autoconf
  • automake

The process for compiling/installing is similar:

autoreconf -v --install .
./configure
make
sudo make install

Contributing

Development of onchanged is ongoing. Please report bugs and suggestions to the issue tracker. Patches and pull requests are welcome as well.

onchanged is licensed under the GNU GPL version 3.