File xdg-screensaver-gnome-dbus.diff of Package xdg-utils.openSUSE_12.1_Update

Source of the patch: http://cgit.freedesktop.org/xdg/xdg-utils/commit/?id=666d65cae0f2e66d33ec0dc48c054afbf16c9e3f
--- scripts/xdg-screensaver	2012-05-21 12:55:11.846122671 +0200
+++ scripts/xdg-screensaver	2012-05-21 12:58:36.269876261 +0200
@@ -613,16 +613,18 @@
 
 screensaver_gnome()
 {
-# 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)
@@ -631,7 +633,13 @@
         ;;
         
         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=$?
         ;;
         
@@ -642,18 +650,31 @@
         
         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
         ;;
openSUSE Build Service is sponsored by