Screenshot

A couple of weeks ago, nixternal blogged about notify-send and irssi in Kubuntu. In response to his entry, I read up on the Desktop Notification Specification and learned that notify-send accepts a mixture of html and xml tags. Why not have the nick that pinged you in bold, so that you can better separate it from the message. The script now also displays both brackets around a nickname, instead of just one.

#!/bin/sh

ssh ryan@192.168.1.101 ": > .irssi/fnotify ; tail -f .irssi/fnotify " |
sed -u '/^#/s|\([^ ]* \)<\([^>]*\)>\(.*\)|\1<b>\&lt;\2\&gt;</b>\3|;/^[^#]/s|[^ ]*|<b>&</b>|' |
while read header message;
do /usr/bin/notify-send -u critical -c im.received -i \
/usr/share/icons/default.kde/48x48/apps/edu_languages.png -t 200000 -- "$header" "$message";
done;

To use the script, install fnotify.pl on the host running irssi. Then place the shell/libnotify script above in your PATH (make sure to edit it, as described below), run it in screen and detach, and then start a new screen for irssi (ssh to the host running irssi). :

  • ryan@192.168.1.101 by the username and host of the computer where irssi is running
  • /usr/share/icons/default.kde/48x48/apps/edu_languages.png by the path to your desired icon

I would like to thank Karl Thornton from #sed for helping me with the regex (aka, writing it), and marthmm from ##linux for helping me debug the script.

EDIT: Sorry, wrong link for fnotify.pl . Save fnotify to .irssi/scripts/fnotify.pl on the host running irssi. Anybody needing help can find me as ryanakca on IRC, or comment to this blog entry (Yes, I just fixed the antispam commenting thingy).