Changes the screensaver_gnome_screensaver to use the GNOME D-Bus API, as documented at http://people.gnome.org/~mccann/gnome-screensaver/docs/gnome-screensaver.html and using the same approach used by the "Use SimulateUserActivity instead of Inhibit for D-Bus screensavers" patch in Bug #26085 and the "Change screensaver_freedesktop's interpretation of GetActive" patch in Bug #29859. Note, also, that GNOME screensaver's "legacy" inhibit support is currently broken ( https://bugzilla.gnome.org/show_bug.cgi?id=579430 ), and gnome-screensaver-command --poke does not work. This patch changes xdg-screensaver so it no longer uses gnome-screensaver-command for control, so--in addition to using the "preferred" API for GNOME screensaver control--it also works around the broken legacy inhibit issue. This patch does not change detectDE or the use of gnome-screensaver-command -q to determine DE. --- xdg-screensaver | 58 42 + 16 - 0 ! 1 file changed, 42 insertions(+), 16 deletions(-) --- xdg-screensaver-cvs-1.48 2010-08-28 22:18:34.000000000 -0400 +++ xdg-screensaver 2010-08-28 22:31:42.000000000 -0400 @@ -713,16 +713,18 @@ screensaver_gnome_screensaver() { -# TODO -# There seems to be a DBUS interface for gnome-screensaver -# See http://lists.mplayerhq.hu/pipermail/mplayer-dev-eng/2006-April/042579.html and -# http://cvs.gnome.org/viewcvs/gnome-screensaver/src/gs-listener-dbus.c?rev=1.36&view=log -# A problem seems to be that Inhibit is tied to the lifetime of the DBUS appname and -# this can not be used from a script +# DBUS interface for gnome-screensaver +# http://people.gnome.org/~mccann/gnome-screensaver/docs/gnome-screensaver.html case "$1" in suspend) - screensaver_suspend_loop gnome-screensaver-command --poke - result=0 + screensaver_suspend_loop \ + dbus-send --session \ + --dest=org.gnome.ScreenSaver \ + --type=method_call \ + /org/gnome/ScreenSaver \ + org.gnome.ScreenSaver.SimulateUserActivity \ + 2> /dev/null + result=$? ;; resume) @@ -731,29 +733,53 @@ ;; activate) - gnome-screensaver-command --activate > /dev/null 2> /dev/null + dbus-send --session \ + --dest=org.gnome.ScreenSaver \ + --type=method_call \ + /org/gnome/ScreenSaver \ + org.gnome.ScreenSaver.SetActive \ + boolean:true \ + 2> /dev/null result=$? ;; lock) - gnome-screensaver-command --lock > /dev/null 2> /dev/null + dbus-send --session \ + --dest=org.gnome.ScreenSaver \ + --type=method_call \ + /org/gnome/ScreenSaver \ + org.gnome.ScreenSaver.Lock \ + 2> /dev/null result=$? ;; reset) # Turns the screensaver off right now - gnome-screensaver-command --deactivate > /dev/null 2> /dev/null + dbus-send --session \ + --dest=org.gnome.ScreenSaver \ + --type=method_call \ + /org/gnome/ScreenSaver \ + org.gnome.ScreenSaver.SimulateUserActivity \ + 2> /dev/null result=$? ;; status) - result=0 - if [ -f "$screensaver_file" ] ; then - echo "disabled" - elif gnome-screensaver-command --query > /dev/null 2> /dev/null; then + status=`dbus-send --session \ + --dest=org.gnome.ScreenSaver \ + --type=method_call \ + --print-reply \ + --reply-timeout=2000 \ + /org/gnome/ScreenSaver \ + org.gnome.ScreenSaver.GetActive \ + | grep boolean | cut -d ' ' -f 5` + result=$? + if [ x"$status" = "xtrue" -o x"$status" = "xfalse" ]; then echo "enabled" + elif [ x"$result" != "x0" ]; then + echo "ERROR: dbus org.gnome.ScreenSaver.GetActive returned '$status'" >&2 + return 1 else - # Something is wrong echo "disabled" fi ;;