jonathan
beluch

 

Posted on March 31, 2011.

I hate having multiple IM windows open. I usually have 3 or 4 accounts I like to log into in addition to irc. The solution to this madness is bitlbee. It’s an IM gateway that supports many IM networks and protocols and brings them all into your irc client of choice.

My setup is to run bitlbee on a remote server. I use irssi as my irc client, and I run it inside a screen session. When I want to chat, I SSH into the remote server, attach to the running irssi screen session and login to my IM accounts.

Since I’m always using multiple workspaces with my xmonad-gnome setup, I sometimes forget to check my irssi window to see if someone has messaged me. I wanted to use notify-send to be able to display a notification when someone messaged me. As it turns out, other people have already done all the hard work.

There are a few different solutions, but here is the solution I found easiest to work with. There are 3 files to deal with. The first is the script for irssi, rnotify.pl, which lives on the remote machine. The other two files, notify-remote and irssi-connect, live on your local machine.

Setup

Download the 3 necessary files from my github gist. I’ve made some minor changes to the two shell scripts found on esaurito’s site.

Remote machine

Follow these steps on the remote machine (where you run screen, irssi).

  1. Place rnotify.pl in ~/.irssi/scripts/.
  2. Create a symlink in ~/.irssi/scripts/autorun/ to the rnotify script
  3. If you already have irssi started, you’ll need to manually load the script this one time. In irssi, /script load rnotify.pl

Local

The shell script requires, autossh and socat.

  1. You’ll need to modify irssi-connect to change a few config options. You’ll have to edit your host to reflect your remote server’s hostname.

  2. You will probably have to edit the notify line as well, to reflect the path to the other file, notify-remote.

  3. If you ever have more than 1 screen session running on your remote server, you’ll have to modify the autossh line to reflect the name of the session.

Usage

Simply execute ./irssi-connect and the magic should happen. If you are somewhere that blocks outgoing connections to port 22, you can pass in an alternate port for SSH, e.g. 443 (you do listen on 443 as well, don’t you?).

The final step is to add an alias to your shell (~/.bashrc in my case). I use alias irc='/home/jon/scripts/irssi-rnotify/fedora-connect'. Now when you want to use irc with notifications, you should simply be able to call irc or irc 443.

Modiftying the Notification Timeout

The script uses notify-send which uses notify-osd to display the notifications. The default timeout is 5 seconds which is way too long, especially if you get multiple messages in a row. Curiously, the man page for notify-send lists a -t, --expire-time=TIME option, which should let you specify the timeout. However, it is ignored!.

If you are on Ubuntu 10.04, you can add Sukochev Roman’s private repository, which contains a modified version of notify-osd. This will allow you to specify the timeout in the notify-remote script. I use 2000 ms.