~willismonroe/ubuntu/precise/xdg-utils/typo-fix-996304

« back to all changes in this revision

Viewing changes to debian/patches/xdg-screensaver-dbus.patch

  • Committer: Package Import Robot
  • Author(s): Daniel Hahler
  • Date: 2011-10-03 16:06:10 UTC
  • Revision ID: package-import@ubuntu.com-20111003160610-xz47jzwvyvvc8ika
Tags: 1.1.0~rc1-2ubuntu6
* Use D-Bus API for GNOME screensaver
  - debian/patches/xdg-screensaver-dbus.patch
  - LP: #805386

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
Description: Use D-Bus API for GNOME screensaver (BR29860)
 
2
Origin: http://cgit.freedesktop.org/xdg/xdg-utils/commit/?id=666d65cae0f2e66d33ec0dc48c054afbf16c9e3f
 
3
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=29860
 
4
Ubuntu-Bug: https://bugs.launchpad.net/xdg-utils/+bug/805386
 
5
Author: Michael T. Dean
 
6
Reviewed-by: Rex Dieter
 
7
Last-Update: 2011-03-31
 
8
Applied-Upstream: http://cgit.freedesktop.org/xdg/xdg-utils/commit/?id=666d65cae0f2e66d33ec0dc48c054afbf16c9e3f
 
9
 
 
10
Index: xdg-utils-1.1.0~rc1/scripts/xdg-screensaver
 
11
===================================================================
 
12
--- xdg-utils-1.1.0~rc1.orig/scripts/xdg-screensaver    2011-10-03 16:03:24.499235760 +0200
 
13
+++ xdg-utils-1.1.0~rc1/scripts/xdg-screensaver 2011-10-03 16:03:43.895236218 +0200
 
14
@@ -809,16 +809,18 @@
 
15
 
 
16
 screensaver_gnome_screensaver()
 
17
 {
 
18
-# TODO
 
19
-# There seems to be a DBUS interface for gnome-screensaver
 
20
-# See http://lists.mplayerhq.hu/pipermail/mplayer-dev-eng/2006-April/042579.html and
 
21
-# http://cvs.gnome.org/viewcvs/gnome-screensaver/src/gs-listener-dbus.c?rev=1.36&view=log
 
22
-# A problem seems to be that Inhibit is tied to the lifetime of the DBUS appname and
 
23
-# this can not be used from a script
 
24
+# DBUS interface for gnome-screensaver
 
25
+# http://people.gnome.org/~mccann/gnome-screensaver/docs/gnome-screensaver.html
 
26
     case "$1" in
 
27
         suspend)
 
28
-        screensaver_suspend_loop gnome-screensaver-command --poke
 
29
-        result=0
 
30
+        screensaver_suspend_loop \
 
31
+        dbus-send --session \
 
32
+                  --dest=org.gnome.ScreenSaver \
 
33
+                  --type=method_call \
 
34
+                  /org/gnome/ScreenSaver \
 
35
+                  org.gnome.ScreenSaver.SimulateUserActivity \
 
36
+                  2> /dev/null
 
37
+        result=$?
 
38
         ;;
 
39
 
 
40
         resume)
 
41
@@ -827,7 +829,13 @@
 
42
         ;;
 
43
 
 
44
         activate)
 
45
-        gnome-screensaver-command --activate > /dev/null 2> /dev/null
 
46
+        dbus-send --session \
 
47
+                  --dest=org.gnome.ScreenSaver \
 
48
+                  --type=method_call \
 
49
+                  /org/gnome/ScreenSaver \
 
50
+                  org.gnome.ScreenSaver.SetActive \
 
51
+                  boolean:true \
 
52
+                  2> /dev/null
 
53
         result=$?
 
54
         ;;
 
55
 
 
56
@@ -838,18 +846,31 @@
 
57
 
 
58
         reset)
 
59
         # Turns the screensaver off right now
 
60
-        gnome-screensaver-command --deactivate > /dev/null 2> /dev/null
 
61
+        dbus-send --session \
 
62
+                  --dest=org.gnome.ScreenSaver \
 
63
+                  --type=method_call \
 
64
+                  /org/gnome/ScreenSaver \
 
65
+                  org.gnome.ScreenSaver.SimulateUserActivity \
 
66
+                 2> /dev/null
 
67
         result=$?
 
68
         ;;
 
69
 
 
70
         status)
 
71
-        result=0
 
72
-        if [ -f "$screensaver_file" ] ; then
 
73
-            echo "disabled"
 
74
-        elif gnome-screensaver-command --query > /dev/null 2> /dev/null; then
 
75
+        status=`dbus-send --session \
 
76
+                          --dest=org.gnome.ScreenSaver \
 
77
+                          --type=method_call \
 
78
+                          --print-reply \
 
79
+                          --reply-timeout=2000 \
 
80
+                          /org/gnome/ScreenSaver \
 
81
+                          org.gnome.ScreenSaver.GetActive \
 
82
+                          | grep boolean | cut -d ' ' -f 5`
 
83
+        result=$?
 
84
+        if [ x"$status" = "xtrue" -o x"$status" = "xfalse" ]; then
 
85
             echo "enabled"
 
86
+        elif [ x"$result" != "x0" ]; then
 
87
+            echo "ERROR: dbus org.gnome.ScreenSaver.GetActive returned '$status'" >&2
 
88
+            return 1
 
89
         else
 
90
-            # Something is wrong
 
91
             echo "disabled"
 
92
         fi
 
93
         ;;