I am currently connected to two Irssi instances coupled with screen. One instance at home, for all my personal IRC needs, and the other at a corporate LAN for secure inter-office IRC messaging. It works great, except when someone tries to get a hold of you (a highlight). I haven’t found any good way for Irssi to notify you when you have been highlighted in a channel. For the past couple years, it hasn’t been bothering me. Then, I found a pretty slick notification system for Irssi, and now I’m hooked. Here is a how-to for getting a GUI notification on your desktop (Gnome or KDE) when someone highlights you in a channel.
For this tutorial, it assumes that Irssi is running on a box separate from your current local machine that you have SSH access to. For example, at work, we have an inter-office server that is running an IRC server. I just SSH into that server from my workstation, fire up screen then Irssi, and connect to it. Irssi is running remotely from my desktop. This is also the case for my personal Irssi session. So, in other words, Irssi is running under screen remotely, and you connect to that session from any other computer via SSH.
First, there is fnotify.pl, a Perl script for Irssi to save the highlights you get in a channel to a file. Save this script to your ~/.irssi/scripts/ directory:
aaron@achilles:~$ mv fnotify.pl ~/.irssi/scripts
Now, if you want the script to run automatically when you launch Irssi, then create a directory called ‘autorun’ in the ~/.irssi/scripts/ directory, and create a symbolic link to fnotify.pl so Irssi starts it up automatically when loaded:
aaron@achilles:~$ cd ~/.irssi/scripts/autorun && ln -s ../fnotify.pl .
Once copied in, either start your Irssi session, or if it is already running, then execute the script in Irssi itself:
When running, it creates a file called ‘fnotify’ in the ~/.irssi/ directory. It is just a plain text file containing all the times you have been highlighted in a channel, one highlight per line.
We need to get the highlights in the appropriate channel to our desktop, so we can visually see them when we are not looking at Irssi itself. You will need notify-send to notify you when someone says your name in a channel. If not installed, install libnotify-bin (Ubuntu/Debian syntax below):
aaron@hercules:~$ sudo aptitude install libnotify-bin
Now, we just need to write a shell script to send us the GUI notifications. This can be done with a simple Bash script (yes, from the same page we got the Perl script for Irssi). Save it anywhere on your local box (not the box that is running the Irssi instance; like your workstation, for example) and execute it (here, I saved it as ‘irssi_notify.sh’).
In the script above, you need to replace ‘remote.system.somewhere’ with your server that you are connecting to. The script makes an SSH connection to the server that you specified, and parses through ~/.irssi/fnotify one line at a time. Each line gets its own notification. That line is then removed from the file, so it doesn’t continuously grow as you continue to get highlighted in channels.
There you go. That’s it! Pretty easy, but a little hackish. But that’s okay. Isn’t that what computers are all about? To automate human tasks? Besides, what fun would it be, if it weren’t hackish? At any rate, a screenshot of the notification results is shown below (you can see the notifications in the bottom-right of the screenshot). But first, a couple caveats:
1. If the screensaver kicks in, and you are highlighted in a channel, you will not receive a GUI notification. This is default behavior with libnotify-bin.
2. By default, Irssi only highlights the nick that mentioned your nick if your nick is first on the line. Otherwise, it is not the case. This can be fixed highlighting the nick that mentions your nick anywhere in the text. Do the following in Irssi:
/hilight -nick (your_nick)
Thanks to Clint for bringing this to my attention! Click for a larger screenshot.