How to annoy your coworkers a little less
Posted Wed, 18 Apr 2007
I'm almost guaranteed to be wearing headphones while at work. I like music.
However, when I leave my desk, I rarely pause mplayer. This leaves my
headphones leaking out some barely audible nois that may annoy coworkers.
I always lock my workstation when I'm not at my desk. How do I automate a solution here?
xscreensaver lets you watch the state of the screensaver. Let's use this to pause mplayer when I leave, and unpause it when I return.
xscreensaver-command -watch \
| while read a; do
echo "$a" | grep '^LOCK' && pkill -STOP mplayer
echo "$a" | grep '^UNBLANK' && pkill -CONT mplayer
done
Running the above, mplayer gets suspended when I lock my workstation, and
resumed when I unlock it.