1
0
Fork 0

Added xscreensaver-watchd

~/.xscreensaver-watch is currently unique to the box
org
Mike Gerwitz 2013-09-10 22:31:26 -04:00
parent 94b6581e1c
commit 444936f1c1
No known key found for this signature in database
GPG Key ID: F22BB8158EE30EAB
2 changed files with 46 additions and 1 deletions

View File

@ -13,6 +13,9 @@ test -f ~/.Xresources-local && xrdb -merge ~/.Xresources-local
test -f ~/.xprofile && source ~/.xprofile
# screensaver can be disabled by creating ~/.noscreensaver (not managed)
test -f ~/.noscreensaver || xscreensaver &
test -f ~/.noscreensaver || {
xscreensaver &
xscreensaver-watchd 2>~/.xscreensaver-watch.log &
}
exec xmonad

View File

@ -0,0 +1,42 @@
#!/bin/bash
#
# Invoke script on xscreensaver state change
#
# Copyright (C) 2013 Mike Gerwitz
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# This simplifies hooking xscreensaver by having a script invoked with each
# state change rather than having to deal with daemon code. Since the script
# (and its executable check) is invoked with each and every state change,
# this has the pleasent and familiar benefit of allowing the user to change
# the script at any point in time without restarting the daemon.
#
# All output from the invoked script is redirected to stderr for logging.
#
# The -watch data is output back to stdout so that it may be used as a part
# of a pipeline in place of xscreensaver-command -watch.
##
# if no script is given as the first argument, default to a standard script
# name in the user's home directory
cmd="${1:-$HOME/.xscreensaver-watch}"
log="${2:-$HOME/.xscreensaver-watch.log}"
# -watch provides data in the format <state> <ts>; we will invoke the script
# once for each line of input, passing those data as two arguments
xscreensaver-command -watch | while read state ts; do
[ -x "$cmd" ] && "$cmd" "$state" "$ts" >&2
echo "$state $ts"
done