pusio-radiograph-tvI was pretty happy with solution to get notifications from Irssi though it had some shortcomings.

A couple of days ago a colleague made me aware of a Perl modules written by another colleague (Anton Berezin) called IPC::Message::Minivan which, it turns out, is perfect for my notification script. Basing the notifications on Minivan combine the speed of using something like Dbus locally (instant notifications) with the convenience of my previous script (notifications over the network, able to handle multiple clients).

This setup consists of three parts: The Minivan daemon, the Irssi script and the notification script.

As always my instructions are based on Ubuntu but should work on most Linux and Unix systems.

Installing the Minivan

IPC::Message::Minivan is not yet available directly through CPAN so we need to install it manually

  1. Download IPC::Messaging and IPC::Message::Minivan (and unpack them).
  2. Install dependencies: sudo apt-get install libjson-xs-perl libregexp-common-perl
  3. One could use dh-make-perl but I chose to install the two modules manually; basically perl Makefile.pl && sudo make install
  4. Create an Upstart script for the Minivan daemon in /etc/init/minivan.conf:
    # minivan - minimalistic message bus
    #
    
    description     "minimalistic message bus"
    
    start on runlevel [2345]
    stop on runlevel [!2345]
    
    expect fork
    respawn
    
    exec /usr/local/bin/minivan -l /var/log/minivan -d
    
  5. Start the Minivan daemon: $ sudo start minivan

Install the Irssi script

  1. Copy the script to ~/.irssi/scripts/notifier-minivan.pl
  2. Load the script inside Irssi: /script load notifier-minivan.pl
  3. If your Minivan is not running on the same machine as Irssi, change the configuration inside Irssi:
    /set minivan\_host your\_hostname - IPC::Message::Minivan is tunnel-able through ssh, see client configuration
  4. Auto-load the script:
    ln -sf ~/.irssi/scripts/notifier-minivan.pl ~/.irssi/scripts/autoload/notifier-minivan.pl

The stuff running on your local machine

It is possible to use autossh to automatically setup the tunnel but since I am always connected to my server (at least when I am in front of a computer) I chose to use normal ssh port forwarding.

In ~/.ssh/config I have

Host my.server.bogus
     LocalForward 6826 localhost:6826

The stuff that actually shows the notifications

I did not want to bother trying to make the script error proof so I simply call the Perl script from a shell script like so

Save the script as ~/bin/start-irssi-notify-client.sh

The notification script requires Desktop::Notify - It is available in the Ubuntu repositories but it is an old version, so let’s use a newer:

$ sudo apt-get install dh-make-perl libnet-dbus-perl
$ cpan2deb Desktop::Notify
$ sudo dpkg -i ~/.cpan/libdesktop-notify-perl*.deb

Copy the script to ~/bin/irssi-notify-client.pl

Remember to make both scripts executable.

The final thing to do is to add the notify client to your desktop environment’s autostart

In GNOME: System -> Preferences -> Startup Applications

Add Startup Program