From 444936f1c10a7a2e09adac36b5b74e7046ef2e92 Mon Sep 17 00:00:00 2001 From: Mike Gerwitz Date: Tue, 10 Sep 2013 22:31:26 -0400 Subject: [PATCH] Added xscreensaver-watchd ~/.xscreensaver-watch is currently unique to the box --- .xinitrc | 5 +++- desktop-bin/xscreensaver-watchd | 42 +++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 1 deletion(-) create mode 100755 desktop-bin/xscreensaver-watchd diff --git a/.xinitrc b/.xinitrc index efb6c88..faaaedd 100644 --- a/.xinitrc +++ b/.xinitrc @@ -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 diff --git a/desktop-bin/xscreensaver-watchd b/desktop-bin/xscreensaver-watchd new file mode 100755 index 0000000..2fb7618 --- /dev/null +++ b/desktop-bin/xscreensaver-watchd @@ -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 . +# +# 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 ; 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