itNew article: under wendy's dress - monochromatic - monochromatic blog: http://blog.z3bra.org Err z3bra.org 70 hgit clone git://z3bra.org/monochromatic URL:git://z3bra.org/monochromatic z3bra.org 70 1Log /scm/monochromatic/log.gph z3bra.org 70 1Files /scm/monochromatic/files.gph z3bra.org 70 1Refs /scm/monochromatic/refs.gph z3bra.org 70 i--- Err z3bra.org 70 1commit 48d975af77ac4e03acc5d504088af9166c778c4b /scm/monochromatic/commit/48d975af77ac4e03acc5d504088af9166c778c4b.gph z3bra.org 70 1parent f456c716360226c645a81c6ff3b8497766db2ba4 /scm/monochromatic/commit/f456c716360226c645a81c6ff3b8497766db2ba4.gph z3bra.org 70 hAuthor: z3bra URL:mailto:willy@mailoo.org z3bra.org 70 iDate: Tue, 31 Mar 2015 23:07:47 +0200 Err z3bra.org 70 i Err z3bra.org 70 iNew article: under wendy's dress Err z3bra.org 70 i Err z3bra.org 70 iDiffstat: Err z3bra.org 70 i A 2015/03/under-wendys-dress.txt | 82 +++++++++++++++++++++++++++++++ Err z3bra.org 70 i M config.mk | 3 ++- Err z3bra.org 70 i M index.txt | 1 + Err z3bra.org 70 i Err z3bra.org 70 i3 files changed, 85 insertions(+), 1 deletion(-) Err z3bra.org 70 i--- Err z3bra.org 70 1diff --git a/2015/03/under-wendys-dress.txt b/2015/03/under-wendys-dress.txt /scm/monochromatic/file/2015/03/under-wendys-dress.txt.gph z3bra.org 70 it@@ -0,0 +1,82 @@ Err z3bra.org 70 i+# [under wendy's dress](#) Err z3bra.org 70 i+## — 31 March, 2015 Err z3bra.org 70 i+ Err z3bra.org 70 i+I've been meaning to write this post for a long time. Err z3bra.org 70 i+ Err z3bra.org 70 i+### who's that chick? Err z3bra.org 70 i+ Err z3bra.org 70 i+[`wendy`](http://git.z3bra.org/cgit.cgi/wendy) is an inotify based directory and Err z3bra.org 70 i+file watch. It is by far the project I'm the most proud of. Err z3bra.org 70 i+Back in the days, I discovered this awesome feature in the kernel: `inotify`. Err z3bra.org 70 i+It's a feature that will make the kernel raise events whenever a file or Err z3bra.org 70 i+directory (let's call them "nodes") will change. Err z3bra.org 70 i+It could be the creation, deletion, move, open, close of this node, and even Err z3bra.org 70 i+more. Err z3bra.org 70 i+ Err z3bra.org 70 i+After seeing there was a C library to interface with the inotify watch/events, I Err z3bra.org 70 i+immediately started writing a small program that would do one simple thing: Err z3bra.org 70 i+notify me when I received an email, and I named my creation **wendy**. Err z3bra.org 70 i+ Err z3bra.org 70 i+At first, all it did was the following: Err z3bra.org 70 i+ Err z3bra.org 70 i+ $ wendy ~/var/mail/INBOX/new -e beep Err z3bra.org 70 i+ watching directory ~/var/mail/INBOX/new Err z3bra.org 70 i+ Err z3bra.org 70 i+And my motherboard's speaker would beep everytime a new file was created in the Err z3bra.org 70 i+specified directory. Err z3bra.org 70 i+ Err z3bra.org 70 i+Now that it was working, I finally decided to make it more and more general, and Err z3bra.org 70 i+it finally reached its current state: a _general purpose node watcher_. Err z3bra.org 70 i+ Err z3bra.org 70 i+ Err z3bra.org 70 i+### how does it work? Err z3bra.org 70 i+ Err z3bra.org 70 i+ wendy -m 768 -f $HOME/directory -e popup "~/directory content updated" Err z3bra.org 70 i+ Err z3bra.org 70 i+The above command will create a popup each time a file is created or deleted in Err z3bra.org 70 i+`~/directory`. Err z3bra.org 70 i+ Err z3bra.org 70 i+`wendy` takes node names, masks, and an optionnal command, mix it up and will Err z3bra.org 70 i+then watch them up with the specified mask, and launch a command upon each event Err z3bra.org 70 i+triggered. Err z3bra.org 70 i+ Err z3bra.org 70 i+Wendy can also read filenames from stdin, to add to its awesomeness ;) Err z3bra.org 70 i+ Err z3bra.org 70 i+ Err z3bra.org 70 i+### play with her! Err z3bra.org 70 i+ Err z3bra.org 70 i+Get a popup when you receive a new e-mail Err z3bra.org 70 i+ Err z3bra.org 70 i+ wendy -m 256 -f ~/var/mail/inbox/new -e popup "you have a new mail" Err z3bra.org 70 i+ Err z3bra.org 70 i+Automatically recompile a C project whenever a source file is changed Err z3bra.org 70 i+ Err z3bra.org 70 i+ find -name "*.c" | wendy -m 8 -e make Err z3bra.org 70 i+ Err z3bra.org 70 i+Send an email to your admin whenever your webserver get an error Err z3bra.org 70 i+ Err z3bra.org 70 i+ wendy -m 8 -f /var/log/httpd/error.log -e sh -c 'tail /var/log/httpd/error.log | mail -s "[ERROR] httpd on $(hostname)" sysadmin@domain.tld' Err z3bra.org 70 i+ Err z3bra.org 70 i+Make an "upload directory" on your system, using ssh and a passphrase-less private key Err z3bra.org 70 i+ Err z3bra.org 70 i+ wendy -v -m 264 -f ~/var/uploads | while read mask file; { Err z3bra.org 70 i+ extension=$(echo $file | sed 's/^.*\.\?//') Err z3bra.org 70 i+ newname=$(tr -cd '[a-z0-9]' < /dev/urandom | fold -w 8i | sed 1q).${extension:-txt} Err z3bra.org 70 i+ scp -i ~/.ssh/id_rsa $file user@domain.tld:/var/www/http/downloads/$newname Err z3bra.org 70 i+ } Err z3bra.org 70 i+ Err z3bra.org 70 i+View manpages on the fly, as you write them Err z3bra.org 70 i+ Err z3bra.org 70 i+ PAGER=cat wendy -m 8 -f wendy.1 -e sh -c "clear; man ./wendy.1" Err z3bra.org 70 i+ Err z3bra.org 70 i+ Err z3bra.org 70 i+the only limit.. Wait, there is no limit! Just let it go (I know you hate me for Err z3bra.org 70 i+saying that...) Err z3bra.org 70 i+ Err z3bra.org 70 i+### contribution Err z3bra.org 70 i+ Err z3bra.org 70 i+If you find any bug, or weird behavior, or anything else, do not hesitate to Err z3bra.org 70 i+drop me an e-mail (willy at mailoo dot org). Err z3bra.org 70 i+ Err z3bra.org 70 i+Keep tweaking ! Err z3bra.org 70 i+ Err z3bra.org 70 1diff --git a/config.mk b/config.mk /scm/monochromatic/file/config.mk.gph z3bra.org 70 it@@ -24,7 +24,8 @@ PAGES = index.html \ Err z3bra.org 70 i 2014/11/avoid-workspaces.html \ Err z3bra.org 70 i 2014/12/so-tox-me-maybe.html \ Err z3bra.org 70 i 2015/01/you-are-the-wm.html \ Err z3bra.org 70 i- 2015/02/do-you-gopher.html Err z3bra.org 70 i+ 2015/02/do-you-gopher.html \ Err z3bra.org 70 i+ 2015/03/under-wendys-dress.html Err z3bra.org 70 i Err z3bra.org 70 i FEEDS = rss/feed.xml Err z3bra.org 70 i EXTRA = css img vid data errors favicon.ico Err z3bra.org 70 1diff --git a/index.txt b/index.txt /scm/monochromatic/file/index.txt.gph z3bra.org 70 it@@ -1,3 +1,4 @@ Err z3bra.org 70 i+* 0x0015 - [under wendy's dress](/2015/03/under-wendys-dress.html) Err z3bra.org 70 i * 0x0014 - [Do you gopher ?](/2015/02/do-you-gopher.html) Err z3bra.org 70 i * 0x0013 - [You are the WM](/2015/01/you-are-the-wm.html) Err z3bra.org 70 i * 0x0012 - [So tox me maybe](/2014/12/so-tox-me-maybe.html) Err z3bra.org 70 .