jasonwryan.com

Miscellaneous ephemera…

IRC Notifications with dzen2

image

I have a persistent tmux session running on a server connected to IRC and I wanted to get notifications whenever someone addressed me, irrespective of whether I was connected to the session, or that particular machine at the time.

I use irssi as my IRC client, and there is a script called fnotify that will print any mentions in a channel to a file. I then configured the fnotify script to write to a folder in Dropbox. Now, whenever I am mentioned in freenode, the file is updated across all my machines.

The next challenge was to translate the updating of the fnotify file into a notification on my current machine. As I don’t use libnotify on my Arch machines, I wanted to make it work with dzen21 Enter a simple shell script:

highlights.sh
#!/bin/sh
dir="$HOME/Dropbox/irssi/"

while inotifywait -qqre attrib "$dir" >/dev/null 2>&1; do
    echo "IRC: You have been pinged..." | dzen2 -p 3
done

I have included this in my $HOME/.xinitrc so that it runs in the background after login. Whenever the metadata (the attrib switch) of the file changes, a dzen2 notification is written to my dwm statusbar with the message.

Simple; but does what I need…

Notes
  1. Dropbox’s API won’t work with dzen2—or with other lightweight notifications like statnot, so I filed a bug report (that was closed without any progress)—hence my having to resort to a home-cooked solution…

Comments