wendy

run arbitrary commands on inotify events
git clone git://iotek.org/wendy
Log | Files | Refs | README | LICENSE

wendy.1 (2718B)


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
.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
.Nm
will check the file or directory for events.
.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:

.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