Image of the glider from the Game of Life by John Conway
Skip to content

Irssi GUI Notify

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:

/RUN fnotify.pl

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.

irssi_notify.png

{ 12 } Comments

  1. Brad Johnson using Firefox 2.0.0.2 on Ubuntu | March 21, 2007 at 8:43 pm | Permalink

    OR, you can disable visual-bell (vbell) in your screenrc so you get an audible beep when events occur.

  2. nixternal using Konqueror 3.5 on Kubuntu | March 21, 2007 at 10:20 pm | Permalink

    Aaron, didn't work for me here. The bash script was giving me issues, and I didn't go through troubleshooting it tonight. I may try again tomorrow.

    Brad, I have tried your way as well, and it doesn't seem to work for me as well.

    I would love to have notification like this though, that is the one thing I miss from Konversation.

  3. MattW using Firefox 2.0.0.2 on Ubuntu | March 22, 2007 at 1:12 am | Permalink

    Bash script had a syntax error in it as pasted from the site. I also tweaked mine so that it doesn't spew the last ten events when it starts up, and has a rather less ridiculously long notification duration.

    ssh maw@wonky.org.uk ": > .irssi/fnotify ; tail -f .irssi/fnotify " | sed -u 's/[

  4. MattW using Firefox 2.0.0.2 on Ubuntu | March 22, 2007 at 1:13 am | Permalink

    Woops, guess I need to escape the script to get it to appear here.

    1
    ssh maw@wonky.org.uk ": > .irssi/fnotify ; tail -f .irssi/fnotify " | sed -u 's/[
  5. MattW using Firefox 2.0.0.2 on Ubuntu | March 22, 2007 at 1:13 am | Permalink

    Okay, maybe not. Sorry about the mess Aaron.

  6. Pharao using Firefox 2.0.0.2 on Ubuntu | March 22, 2007 at 4:21 am | Permalink

    I get a

    1
    2
    Irssi: Error loading module fnotify/core: /usr/lib/irssi/modules/libfnotify_core.so: cannot open shared object
              file: No such file or directory

    running Feisty...

  7. Ben Armstrong using Debian IceWeasel 2.0.0.2 on Debian GNU/Linux | March 22, 2007 at 4:26 am | Permalink

    Nice idea, except I'm not too fond of popup notifications. Might be fun to try to make this work with zenity --notification instead, for a less "in your face" solution.

  8. Brian using Firefox 2.0.0.2 on Ubuntu | March 22, 2007 at 6:41 am | Permalink

    Would be nice mentioning where you got it from.

  9. Aaron using Debian IceWeasel 2.0.0.2 on Debian GNU/Linux 64 bits | March 22, 2007 at 9:38 am | Permalink

    Brad- I have never gotten that to work. Not sure what I am doing wrong.

    Nixternal- I works in KDE. I'll get with you online, and we'll figure it out.

    MattW- See my next post on the blog. It's missing a semi-colon.

    Pharo- Not sure what your problem is. You may need to load perl into Irssi. Try in Irssi:

    1
    /load perl

    Ben- Yeah. This definitely is not for everyone. If you getting working with zenity, post your solution. I'd be interested seeing it in action.

    Brian- I posted two links to the same site, giving attributed credit where credit is due, as well as to Clint, who brought it to my attention to begin with.

  10. Pedro Algarvio, aka, s0undt3ch using Firefox 2.0.0.3 on Ubuntu | May 10, 2007 at 2:30 pm | Permalink

    You might also be interested on Irssi Notification, a cleaner approach for the same end result which uses irssi's proxy's.

  11. Rolf using Firefox 2.0.0.3 on Ubuntu | May 16, 2007 at 7:39 am | Permalink

    Pharao: The article should have said

    1
    /SCRIPT RUN fnotify.pl

    I saw the same message when i did try using /run. It works perfectly here, but I had to modify the script to watch a whole channel instead.

  12. Jared Quinn using Firefox 2.0.0.6 on GNU/Linux | September 25, 2007 at 1:50 am | Permalink

    I use libnotify, screen and irssi over ssh. I did't like any of the solutions i found and decided to implement it myself using the terminal 'print' functionality available on xterm and other similiar terminals.

    irssi sends the print escape codes and the info I want to include in the notify wrapped in the appropriate escape codes and XTerm "prints" it to a shell script which calls notify-send.

    Full details at http://jaredquinn.info/it-related/technical/unix/2007.09.25/libnotify-with-irssi-over-ssh/

{ 7 } Trackbacks

  1. nixternal » Notify Works in Kubuntu | March 22, 2007 at 10:22 am | Permalink

    [...] response to Aaron’s blog posts (Part 1, Part 2) about IRSSI and libnotify to send you a notification upon highlight, well it works great [...]

  2. [...] response to Aaron’s blog posts (Part 1, Part 2) about IRSSI and libnotify to send you a notification upon highlight, well it works great [...]

  3. [...] You may also remember all that talk going around some time ago about an irssi notify script tied into libnotify.  I use that as well (see previous information here). [...]

  4. [...] You may also remember all that talk going around some time ago about an irssi notify script tied into libnotify.  I use that as well (see previous information here). [...]

  5. Aaron Toponce : Pimp My Irssi | January 6, 2008 at 2:35 pm | Permalink

    [...] there is no way to notify me when I receive an IM or highlight and I’m not viewing Irssi. Coupled with a simple bash script, I can receive those [...]

  6. [...] Output all hilighted messages to a log file (using fnotfiy), and tail that log file with a second ssh session into a local script that calls libnotify. Sub-optimal, because it requires manually running a second ssh session, and restarting it in the event of network issues. Example [...]

  7. [...] response to Aaron’s blog posts (Part 1, Part 2) about IRSSI and libnotify to send you a notification upon highlight, well it works great [...]

Switch to our mobile site