Skip to content

Instantly share code, notes, and snippets.

@greggerz
Created July 25, 2013 17:00
Show Gist options
  • Save greggerz/6081719 to your computer and use it in GitHub Desktop.
Save greggerz/6081719 to your computer and use it in GitHub Desktop.
Script to watch for xscreensaver lock/unblank events and update pidgin statuses
#!/bin/bash
#
# Handles setting pidgin statuses based on lock/unblank events from
# xscreensaver
#
# Customization of gist found here by Ron DuPlain:
# https://gist.github.com/rduplain/3852987
#
lock()
{
state="locked"
status=$(/usr/bin/purple-remote getstatus)
message=$(/usr/bin/purple-remote getstatusmessage)
$(/usr/bin/purple-remote setstatus?status=away)
}
unblank()
{
if [ "$state" == "locked" ];
then
state=""
$(/usr/bin/purple-remote setstatus?status=$status&message=$message)
fi
}
xscreensaver-command -watch | while read a
do
echo "$a" | grep -q '^LOCK' && lock
echo "$a" | grep -q '^UNBLANK' && unblank
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment