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

commit f0a10e88853dd32896c2275a2165bb60b35bdd3f
parent be93ac0426a2fedea1121fdc094cb6e1506e5d9c
Author: z3bra <willyatmailoodotorg>
Date:   Mon,  1 Feb 2016 13:45:28 +0100

Rewrite wendy.1 using mdoc format

Mwendy.1 | 262++++++++++++++++++++++++++++++++++---------------------------------------------
1 file changed, 114 insertions(+), 148 deletions(-)

diff --git a/wendy.1 b/wendy.1 @@ -1,151 +1,117 @@ -./" wendy manual page - section 1 (general commands) -.TH WENDY 1 2015-03-31 Linux -.SH NAME -.B wendy -\- directory and file watcher based on inotify -.SH SYNOPSIS -.B wendy -.BI \-m\ mask -.RB [ \-lv ]\ [ \-f -.IR file ] -.RB [ \-t -.IR timeout ] -.RB [ \-v ] -.BI [ \-e\ command\ [arg, ..]] -.SH DESCRIPTION -.B wendy -watches for events in a directory or its files and executes a command when an -inotify event is triggered. -.SH OPTIONS -.TP -.B \-l -Outputs a list of masks -.B wendy -can watch for and their mask values. -.TP -.B \-v -Verbose. -.B wendy -will output the mask of the event caught, followed by a tab, and then the name -of the file or directory that the event was caught in. -.TP -.BI \-f\ file -Specifies the file or directory to watch events in. You can specify multiple files by providing multiple -.B -f -flags. If no file is specified, then -.B wendy -will read filenames from stdin. -.TP -.BI \-t\ timeout +.Dd 2013-06-02 +.Dt WENDY 1 +.Os POSIX.1-2008 +.Sh NAME +.Nm wendy +.Nd inotify based directory and file watcher +.Sh SYNOPSIS +.Nm wendy +.Op Fl lv +.Op Fl m Ar mask +.Op Fl f Ar file +.Op Fl t Ar timeout +.Op cmd Op Ar arg.. +.Sh DESCRIPTION +.Nm +watches for events in a directory or its files and executes +.Ar cmd +when an inotify event is triggered. +.Bl -tag -width Ds +.It Fl l +List mask values to be used with +.Fl m . +.It Fl v +Enable verbose mode +.It Fl m Ar mask +Sets the mask of events to watch for (default: IN_MODIFY|IN_CLOSE_NOWRITE). +Refer to the MASKS section of this manual page for more details. +.It Fl f Ar file +Specifies the file or directory to watch events in. You can specify multiple +files by providing the +.Fl f +flag multiple times. +If no file is specified, then +.Nm +will read file names from stdin. +.It Fl t Ar timeout Sets the delay -.B wendy +.Nm will check the file or directory for events. -.I timeout -is in seconds. -.TP -.BI \-m\ mask -Sets the mask of events to watch for. Refer to the -.B MASKS -section of this manual page for more details. you can specify multiple masks by -providing multiple -.B -m -flags. Flags are processed from left to right, so you can watch different masks -on different nodes in a single command (Refer to the -.B EXAMPLE -section for examples on how to use this flag) -.TP -.BI \-e\ command -Execute -.I command -when the events have been caught. -.B NOTE: This must be the last argument to any call to wendy! -.SH MASKS -A mask is a number that -.B wendy -uses to find out what events it should check for. When using -.BI \-m\ mask\fR, -.I mask -will either be a number or a sum of numbers from the table below: -.TS -l l ---- -l l. -MASK VALUE -IN_ACCESS 1 -IN_MODIFY 2 -IN_ATTRIB 4 -IN_CLOSE_WRITE 8 -IN_CLOSE_NOWRITE 16 -IN_OPEN 32 -IN_MOVED_FROM 64 -IN_MOVED_TO 128 -IN_CREATE 256 -IN_DELETE 512 -IN_DELETE_SELF 1024 -IN_MOVE_SELF 2048 -IN_ALL_EVENTS 4095 -IN_UNMOUNT 8192 -.TE +.Ar timeout +is in seconds (default: 1). +.El +.Sh MASKS +The mask is a numeric value passed to inotify to specify the events that should +be raised. Multiple events can be registered by summing them up, and passing +the result to the +.Fl m +flag. The mask can take any of the values below, or a sum of them: -.SH EXAMPLES - -.SS Watching single events -This command will watch -.B IN_CREATE -events in the given directory, and play a sounds whenever a file is created in -this directory. This can be useful to get notified of new incoming emails -(fetched locally) -.nf -wendy -m 256 -f ~/mail/INBOX/new -e play /usr/share/sound/bell.wav -.fi - -.SS Watching for multiple events -To watch multiple events, you just need to sum them up before giving the mask to -.B wendy -\. For example, here is how you'd watch both -.B IN_MOVED_FROM (64) -and -.B IN_MOVED_TO (128) -events on a directory: 128 + 64 = 192 -.nf -wendy -m 192 -f ~/var/directory -v -.fi - -.SS Watching multiple files -.B wendy -gives you two different ways to watch multiple files. Either by providing -multiple -.B \-f -flags, or by feeding it from stdin. Let's say you have the following structure: -.nf - . - |-- Makefile - |-- library.c - |-- library.h - `-- program.c -.fi -If you want to automatically run -.B make -whenever a C source file is modified, you can use the following commands -.nf -wendy -m 8 -f library.c -f program.c -e make -.fi -OR -.nf -find -name '*.c' | wendy -m 8 -e make -.fi - -.SS Using different masks on different files -The order of the flags provided matters. So if you want to watch mutliple -events, you can simply tidy the arguments to do what you want. -This example will raise both -.B IN_CREATE -events in the given directory, and -.B IN_ACCESS -events on existing files -.nf -wendy -v -m 256 -f /var/log -m 1 -f /var/log/message -f /var/log/auth -.fi - -.SH SEE ALSO -.BR inotify (7) +.Bl -bullet -compact +.It +IN_ACCESS 1 +.It +IN_MODIFY 2 +.It +IN_ATTRIB 4 +.It +IN_CLOSE_WRITE 8 +.It +IN_CLOSE_NOWRITE 16 +.It +IN_OPEN 32 +.It +IN_MOVED_FROM 64 +.It +IN_MOVED_TO 128 +.It +IN_CREATE 256 +.It +IN_DELETE 512 +.It +IN_DELETE_SELF 1024 +.It +IN_MOVE_SELF 2048 +.It +IN_ALL_EVENTS 4095 +.It +IN_UNMOUNT 8192 +.El +.Sh ENVIRONMENT +.Bl -tag -width Ds +.It Ev WENDY_INODE +Name of the inode concerned by the event +.It Ev WENDY_EVENT +Numeric value of the event triggered +.El +.Sh EXAMPLES +.Ss Watch single events +This command will make wendy play a sound whenever a file is created in the +direcotry specified. It might be used as a "new mail" notifier. +.Bd -literal -offset Ds +wendy -m 256 -f ~/Mails/INBOX/new play /usr/share/sound/bell.wav +.Ed +.Ss Watch multiple events +You can watch multiple events by passing the sum of their numerical value to +the +.Fl m +flag. This command will watch both IN_CREATE (256) and IN_DELETE (512) in the +current directory, and report these events to stdout (same effect as using the +.Fl v +flag) +.Bd -literal -offset Ds +wendy -m 768 -f . sh -c 'printf "%s\\t%s\\n" $WENDY_EVENT $WENDY_INODE' +.Ed +.Ss Watch multiple files +The two following commands are equivalent and will run +.Xr make 1 +whenever a .c of .h file change. +.Bd -literal -offset Ds +wendy -f foo.c -f foo.h -f lib/libbar.c make +find -name '*.[ch]' | wendy make +.Ed +.Sh SEE ALSO +.Xr inotify 7, +.Xr entr 1 +.Sh AUTHORS +.An Willy Goiffon Aq Mt willy@mailoo.org