Created
July 25, 2013 17:00
-
-
Save greggerz/6081719 to your computer and use it in GitHub Desktop.
Script to watch for xscreensaver lock/unblank events and update pidgin statuses
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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