Graphical notifications for centerim

Using centerim's external configuration file makes it pretty easy to get notified about incoming messages. However, if you would add something like the following to your ~/.centerim/external, you'd be informed about *every* single incoming message, which doesn't make much sense, at least not in my eyes....

%action  notification
event msg
proto all
status all
options nowait

%exec
#!/bin/bash
#msg=`cat`
nick=$(head -n 1 $CONTACT_INFODIR/info)
echo "new message from $nick"  | dzen2 -bg red -fg white -p

To deal with this problem, I wrote two small perl scripts: centerim_notify.pl & offline.pl. The first one caters for the notifications and stores the screen name of your IM-buddy in a hidden file (~/.centerim/.seen) so you won't get notified again. The latter removes a chat partner from the list, when he logs off. So, here's how to use it:

  • Save both scripts to ~/.centerim/scripts/ and make them executable (chmod +x ...)
  • Put the following into your ~/.centerim/external:
%action  notification
event msg
proto all
status all
options nowait

%exec
#!/bin/bash
nick=$(head -n 1 $CONTACT_INFODIR/info)
~/.centericq/scripts/centerim_notify.pl "$nick"

%action offline
event offline
proto all
status all
options nowait

%exec
#!/bin/bash
nick=$(head -n 1 $CONTACT_INFODIR/info)
~/.centericq/scripts/offline.pl "$nick"
  • Create a bash alias that deletes the "seen-file" everytime you launch centerim:
echo "alias centerim='rm -f ~/.centericq/.seen && centerim -o'" >> ~/.bashrc
  • Run centerim!

Requirements: dzen2, perl and centerim ;-)