Adding notifications to finch

So, we use XMPP for our internal chat system at work, but I hate pidgin and empathy’s not much better. Naturally I searched for command line alternatives and the least offensive one I could find was finch, which admittedly uses libpurple on the backend, so it’s really pidgin, but at least it’s in a terminal now. Of course, I lost all my notifications of incoming messages, which isn’t cool, so I cooked up a simple script and call it instead of playing sound through finch. In finch’s “sounds” menu, simply change “Automatic” to “command”. In ubuntu, you’ll need two new packages:

sudo aptitude install libnotify-bin mplayer

And you’ll need this script, and to remember the path to it:

#!/bin/bash

latest_line=`find ~/.purple/logs/jabber/ -mtime -1 -printf "%T@ %Tx %TX %p\n" | sort -n -r | head | cut -d ' ' -f 2- | awk '{print $NF}' | head -1 | xargs tail -1 | sed -e 's#<[^>]*>##g'`
mplayer $1 >/dev/null 2>&1 &
notify-send "`echo $latest_line | cut -d ':' -f 3 | awk -F ')' '{print $2}'`" "`echo $latest_line | cut -d ':' -f 4-`"
This entry was posted in Ubuntu. Bookmark the permalink.

One Response to Adding notifications to finch

  1. eedeep says:

    Hey thanks a lot for this…very handy. The only thing was that for me the find line you posted didn’t quite work for me…I tweeked it a bit and got it working for me by doing this:

    latest_line=`find ~/.purple/logs -type f -mtime -1 -printf “%T@ %Tx %TX %p\n” | sort -n -r | head | cut -d ‘ ‘ -f 2- | awk ‘{print $NF}’| head -1|xargs tail -1| sed -e ‘s#]*>##g’`
    4 mplayer $1 >/dev/null 2>&1 &
    5 notify-send “`echo $latest_line | cut -d ‘:’ -f 3 | awk -F ‘)’ ‘{print $2}’`” “`echo $latest_line | cut -d ‘:’ -f 4-`”

    The find line is the only one that’s slightly different to what you posted above. Thanks again!

Leave a Reply