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.