May 15, 2009

Keyboard shortcut for Gwibber

I've recently joined Twitter and its great! I installed Gwibber and its a nifty client. Being the rodent averse person I am, I had to find a way to have a keyboard shortcut for this trivial task. So, what did I do? I wrote this:

#!/bin/bash

ppath=/usr/bin/gwibber
prg=Gwibber
prgstr=gwibber
if [ -z "$(ps -eaf |grep -i $ppath|grep -v grep)" ] ; then
    nohup $prgstr &
    sleep 1
fi
[ -z "$(wmctrl -l |grep -i $prg|grep -v grep)" ] && $prgstr
wmctrl -a "${prg}"

This launches Gwibber if its already not running. Otherwise, it just brings the window to the foreground. Best part of Gwibber is, it ensures you only have one instance running so this works even when Gwibber is iconified on gnome-panel.Bless you wmctrl

My HP Laptop had an "Information" key which was lying idle. So, I fired up "xev", got the keycode, assigned it to a virtual key (F21 in this case) and attached the above script to it in Compiz! So now, I just need to press one key to check my Twitter feeds :)

 Next step, modify it to work as a toggle key...