Skip to content

Instantly share code, notes, and snippets.

@ryo1kato
Created April 5, 2012 02:38
Show Gist options
  • Save ryo1kato/2307584 to your computer and use it in GitHub Desktop.
Save ryo1kato/2307584 to your computer and use it in GitHub Desktop.
Watch screensaver activity and log
#!/bin/bash
# watch screensaver's lock/unlock activity and log
log=$HOME/usr/var/log/screensaver.log
DIE () {
touch $log
echo "ERROR: $*" | tee -a $log >&2
}
# c.f. http://people.gnome.org/~mccann/gnome-screensaver/docs/gnome-screensaver.html#gs-intro
dbuswatch="type='signal',interface='org.gnome.ScreenSaver',member='ActiveChanged'"
touch $log
dbus-monitor "$dbuswatch" | while read line
do
case $line in
boolean*)
datetime=`date +%Y%m%d-%H:%M:%S`
echo "$datetime ActiveChanged: $line" >> $log
;;
*)
continue
;;
esac
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment