wendy

inotify based node watcher
git clone git://git.2f30.org/wendy.git
Log | Files | Refs | README | LICENSE

wendy.1 (3273B)


      1 .Dd 2013-06-02
      2 .Dt WENDY 1
      3 .Os POSIX.1-2008
      4 .Sh NAME
      5 .Nm wendy
      6 .Nd inotify based event watcher
      7 .Sh SYNOPSIS
      8 .Nm wendy
      9 .Op Fl adlrv
     10 .Op Fl m Ar mask
     11 .Op Fl w Ar inode
     12 .Op command Op Ar args...
     13 .Sh DESCRIPTION
     14 .Nm
     15 watches for events in a directory or its files and executes
     16 .Ar cmd
     17 when an inotify event is triggered.
     18 .Bl -tag -width Ds
     19 .It Fl a
     20 Hidden mode. Entries whose name start with a . will be listed and trigger
     21 an event.
     22 .It Fl d
     23 Directory mode. Only directories will be watched, while regular
     24 files will be skipped (even if explicitely set with -w). See IN_ONLYDIR
     25 from
     26 .Xr inotify 7 .
     27 .It Fl l
     28 List events along with their numeric values.
     29 .It Fl r
     30 Recursive mode. Everytime an IN_CREATE event is triggered,
     31 a watch is added on the target file/directory.
     32 .It Fl v
     33 Verbose mode. Each triggered event is printed along with the path,
     34 as provided on the command line. In the case of directories, the path
     35 triggering the event is concatenated to the directory path.
     36 .It Fl m Ar mask
     37 Sets the mask for events you are interested in (see MASKS for more details).
     38 default: IN_CREATE|IN_DELETE|IN_DELETE_SELF|IN_MODIFY|IN_MOVE|IN_MOVE_SELF|IN_CLOSE_WRITE
     39 .It Fl w Ar inode
     40 Specifies the file or directory to watch events in. You can specify multiple
     41 files by providing the
     42 .Fl w
     43 flag multiple times. If no watcher is added with the -w flag,
     44 .Nm
     45 will read path names from
     46 .Ar stdin ,
     47 one per line.
     48 .El
     49 .Sh MASKS
     50 The mask is a numeric value passed to inotify to specify the events that should
     51 be raised. Multiple events can be registered by summing them up, and passing
     52 the result to the
     53 .Fl m
     54 flag. The mask can take any of the values below, or a sum of them:
     55 
     56 .Bl -bullet -compact
     57 .It
     58 IN_ACCESS          1
     59 .It
     60 IN_MODIFY          2
     61 .It
     62 IN_ATTRIB          4
     63 .It
     64 IN_CLOSE_WRITE     8
     65 .It
     66 IN_CLOSE_NOWRITE   16
     67 .It
     68 IN_CLOSE           24
     69 .It
     70 IN_OPEN            32
     71 .It
     72 IN_MOVED_FROM      64
     73 .It
     74 IN_MOVED_TO        128
     75 .It
     76 IN_MOVE            192
     77 .It
     78 IN_CREATE          256
     79 .It
     80 IN_DELETE          512
     81 .It
     82 IN_DELETE_SELF     1024
     83 .It
     84 IN_MOVE_SELF       2048
     85 .It
     86 IN_ALL_EVENTS      4095
     87 .It
     88 IN_UNMOUNT         8192
     89 .El
     90 .Sh ENVIRONMENT
     91 .Bl -tag -width Ds
     92 .It Ev WENDY_INODE
     93 Name of the inode concerned by the event
     94 .It Ev WENDY_EVENT
     95 Name of the event triggered (eg. "CREATE")
     96 .El
     97 .Sh EXAMPLES
     98 Whenever an IN_CREATE (256) event is triggered in the Maildir folder
     99 INBOX, a sound is played:
    100 .Bd -literal
    101   wendy -m 256 -w ~/mail/INBOX/new play /usr/share/sound/bell.wav
    102 .Ed
    103 .Pp
    104 Use a sub-shell to print event name and path to stdout, showcasing the
    105 variables exported internally (this replicates the
    106 .Fl v
    107 switch):
    108 .Bd -literal
    109   wendy -m 768 -w . sh -c 'echo $WENDY_EVENT $WENDY_INODE'
    110 .Ed
    111 .Pp
    112 Rebuild a project when one of its source files changes:
    113 .Bd -literal
    114   find . -name '*.[ch]' | wendy make
    115 .Ed
    116 .Pp
    117 This example will only watch directory nodes, and will monitor every
    118 new directory created, thus propagating event monitoring inside the tree.
    119 Note that events happening on files withing these directories will
    120 still be reported, making the following command suitable for
    121 synchronizing two directories:
    122 .Bd -literal
    123   find /src -type d | wendy -rd -m 970 rsync -av --delete /src /dest
    124 .Ed
    125 .Sh SEE ALSO
    126 .Xr inotify 7 ,
    127 .Xr rsync 1
    128 .Sh AUTHORS
    129 .An Willy Goiffon Aq Mt dev@z3bra.org