--- /usr/bin/xdg-screensaver 2010-09-15 13:08:29.000000000 +0200 +++ /tmp/xdg-screensaver 2010-10-02 16:41:32.494406314 +0200 @@ -335,6 +335,7 @@ elif [ x"$GNOME_DESKTOP_SESSION_ID" != x"" ]; then DE=gnome; elif `dbus-send --print-reply --dest=org.freedesktop.DBus /org/freedesktop/DBus org.freedesktop.DBus.GetNameOwner string:org.gnome.SessionManager > /dev/null 2>&1` ; then DE=gnome; elif xprop -root _DT_SAVE_MODE 2> /dev/null | grep ' = \"xfce4\"$' >/dev/null 2>&1; then DE=xfce; + else DE="" fi } @@ -429,8 +430,12 @@ xscreensaver) screensaver_xscreensaver "$1" ;; - esac + '') + screensaver_xserver "$1" + ;; + esac + if [ "$1" = "suspend" ] ; then # Save DPMS state if xset -q | grep 'DPMS is Enabled' > /dev/null 2> /dev/null; then @@ -676,6 +681,49 @@ return 1 fi ;; + + *) + echo "ERROR: Unknown command '$1'" >&2 + return 1 + ;; + esac +} + +screensaver_xserver() +{ + case "$1" in + suspend) + xset s off > /dev/null + result=$? + ;; + + resume) + xset s default > /dev/null + result=$? + ;; + + activate) + xset s activate > /dev/null + result=$? + ;; + + reset) + xset s reset > /dev/null + result=$? + ;; + + status) + timeout=`xset q | sed '/^Screen Saver:/,/^[^ ]/ { s/.*timeout: *\([0-9]*\).*/\1/; t }; d'` + result=$? + if [ "$timeout" -gt 0 ]; then + echo "enabled" + elif [ "$timeout" -eq 0 ]; then + echo "disabled" + else + echo "ERROR: xset q did not report the screensaver timeout" >&2 + return 1 + fi + ;; *) echo "ERROR: Unknown command '$1'" >&2