thunderkeys.net
thunderkeys.net

Wed, Jan 24 2007


I setup things at work to auto-pause amarok when I lock the screen using kdesktop_lock. There were some example scripts that worked by checking the screen blank status using dcop in a never-ending while loop and sleeping, but I didn't want that many dcop calls constantly being spawned. These steps need to be done as root, unless you have some custom setup.

First, create the following shell script as /usr/bin/kdesktop_lock.sh:

#!/bin/sh

amarok_status=`dcop amarok player status`
amarok_is_playing=`dcop amarok player isPlaying`

if [ "x$amarok_is_playing" = "xtrue" -a $amarok_status -ne 1 ]; then
    dcop amarok player pause
fi

/usr/bin/kdesktop_lock.real $*

if [ "x$amarok_is_playing" = "xtrue" ]; then
    dcop amarok player play
fi

This dpkg-divert stuff is just so debian package upgrades won't clobber the setup.

/usr/sbin/dpkg-divert --divert /usr/bin/kdesktop_lock.real --rename /usr/bin/kdesktop_lock

Then setup a symlink from kdesktop_lock.sh to kdesktop_lock, and fix modes on the shell script:

ln -s /usr/bin/kdesktop_lock.sh /usr/bin/kdesktop_lock
chmod a+x /usr/bin/kdesktop_lock.sh

Now when you lock your screen an amarok is playing, it should pause your music. When you unlock the screen, it will automatically resume.



I put up some new picture galleries taken in December and January.


blosxom logo

Friends

Karen
Richard
Geoff
Steve
Jon
North Glade Inn

Other Reading

Previous entries

January
Sun Mon Tue Wed Thu Fri Sat
 
24
     

Archives: 2007, 2006, 2005, 2004, 2003

Blog categories