Open / Play / Pause Rhythmbox with single key

It would be slightly more useful if when I hit the play/pause button on my keyboard and rhythmbox wasn’t open it would open up for me.  I first tried to do the obvious and set the same key to open my media player and play/pause in the Gnome keyboard shortcuts app.  Computer says no.  I then remembered that compiz will let you run arbitrary commands from keyboard shortcuts, so I just needed to work out exactly what command I wanted to run to get this done…

A bash script seemed like the most obvious solution.  In the end I came up with the following:

#!/bin/sh
#rhythmScript.sh
app='rhythmbox'

if ! (ps ax | grep -v grep | grep $app > /dev/null)
then
    rhythmbox &
else
    rhythmbox-client --play-pause
fi

First, it looks to see if any process with the name ‘rhythmbox’ is running.  If no process is running it launches it, otherwise it toggles play/pause on rhythmbox.  Note the grep -v, this is needed else the grep rhythmbox process will get returned and screw my if statement up.  Save the script, make it executable and then add it as a command in compiz-settings associated with the key of your choice.


Linux v Apple slim usb keyboard

I needed a new keyboard as the Logitech one I had just wasn’t cutting it. I was looking at something nice and solid, rather than some cheap eBuyer job. Keyboards that took my fancy included the rather lovely Das Keyboard and Logitech’s new Illuminated Slim Keyboard. However, the Das keyboard is