Site Navigation

Archive for the ‘irssi’ Category

libnotify over ssh enhanced

Monday, June 16th, 2008

Bene shares some modifications he made to my libnotify over ssh post.

libnotify with irssi over ssh

Tuesday, September 25th, 2007

I’m an avid IRC user, sitting 24×7 usually connected to 5 server and 12 regular channels, and the only client I’m completely satisfied using is irssi. I run irssi on a remote server so I can easilly connect to it via ssh from wherever I am. I run it under screen so that I can re-attach to the same session from where ever I am and even have the same session shared across all my home PCs so i can look in and see whats happening whenever I want.

Recently I began playing with dbus alot, including libnotify. I found some irssi plugins for people running irssi locally to integrate with libnotify, but all the solutions by people for doing this remotely involved re-establishing ssh connections for each message and various other overheads that I was not comfortable with. The solution was obvious, to me - ssh needed dbus forwarding support. Well I don’t have the time nor experiece with the ssh code base to do it, a workaround was needed.

It didn’t take long for one to become apparent.

Nobody I know uses a relatively unheard of terminal capability known as terminal printing. This allows control characters sent to your terminal to turn on/off a locally connected printer. The content isn’t displayed by your terminal, but captured. Excellent, we could utilise this functionality for carrying a payload to the local machine, the connection is already there and the facility should be available in most terminal emulators (I’m a purist and use basic xterm which supports it).

What do I need?

  • You need a terminal emulator that supports local printing. I’m using xterm 229
  • libnotify and libnotify-bin, this includes the notify-send package
  • a libnotify daemon (I’m using notification-daemon-xfce)

Obviously you’re already using irssi as an IRC/IM client, and you’re probably running it over ssh (and hopefully screen too if you are). But that is outside the scope of this article.

How is it done?

First thing we do is install the local handler script. This is the script that we configure xterm to pipe the content to be “printed” to.

Here is the script:


#!/bin/bash
cat - | {
nt_icon="gtk-dialog-info"
nt_time=5000
nt_head="Notify"
nt_text="Error Occured"
nt_type="Message"
while read k v
do
case $k in
TYPE) nt_type=$v;;
ICON) nt_icon=$v;;
CONTENT) nt_text=$v;;
TIMEOUT) nt_time=$v;;
SUBJECT) nt_head=$v;;
esac
done
notify-send -i "$nt_icon" -c "$nt_type" -t $nt_time -- "$nt_head" "$nt_text"
}

Grab it from here and put it somewhere sensible and make it executable.

The next thing that is needed is to configure XTerm to locally print using the script above. I use X resources for this. Infact I define a class in my Xresources called irssi and start xterm with a ‘-class irssi’ option for my IRCing.

If you don’t want a seperate class for irc, you can use the following lines. If you do want a class specific for your IRCing replace XTerm with the class name you like. The printer command should also point to wherever you put the script above.


*XTerm*printerAutoClose: true
*XTerm*printerCommand: /home/jared/bin/notifier

The last thing you need is the irssi plugin. I’ve uploaded it and attached it to this document, you need to download it and run it with /script load notify.pl inside irssi.

It is written by Luke Macken and Paul W Frields, i’ve adapted it deliver it’s payload to STDERR wrapped with ESC[5i (turn printer on) and ESC[4i (turn printer off)

notify.pl.gz

Happy IRCing!