Last active
July 15, 2020 14:43
-
-
Save nitheeshkl/fcab35b3fe566344545bf41a88c9998e to your computer and use it in GitHub Desktop.
watch xscreensaver for lock and unlock
This file contains hidden or 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/sh | |
# Watch xscreensaver and react to status changes. | |
# | |
# Replaced my previous perl-based recipe with this: | |
# http://semicomplete.googlecode.com/svn/tools/xscreensaver-watch.sh | |
# | |
# Include somewhere in X session startup with: | |
# | |
# xscreensaver-watch & | |
lock() { | |
# Log this somewhere with `date` instead of just echoing. | |
echo `uname -n` screen is now blank | |
# Do other things here, like stop music playback & mute speakers. | |
} | |
unlock() { | |
# Log this somewhere with `date` instead of just echoing. | |
echo `uname -n` screen is now unblank | |
# Do other things here, like resume music playback & unmute speakers. | |
} | |
xscreensaver-command -watch | while read a; do | |
echo "$a" | grep -q '^LOCK' && lock | |
echo "$a" | grep -q '^UNBLANK' && unlock | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment