summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRex Dieter <rdieter@fedoraproject.org>2011-03-31 08:17:41 -0500
committerRex Dieter <rdieter@fedoraproject.org>2011-03-31 08:17:41 -0500
commit666d65cae0f2e66d33ec0dc48c054afbf16c9e3f (patch)
tree15c7541a8db7d695a5fdad2b8a4fb17f07799296
parentddb03d9f6b673ef67c0b0ab04b6d0482b4c0b4d8 (diff)
Use D-Bus API for GNOME screensaver (BR29860)
-rw-r--r--ChangeLog1
-rw-r--r--scripts/xdg-screensaver.in51
2 files changed, 37 insertions, 15 deletions
diff --git a/ChangeLog b/ChangeLog
index da29fe1..1fb02dd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,7 @@
2011-03-31 Rex Dieter <rdieter@fedoraproject.org>
* Don't overwrite a /usr/share/applications/defaults.list symlink (BR35794)
+ * Use D-Bus API for GNOME screensaver (BR29860)
2011-03-28 Rex Dieter <rdieter@fedoraproject.org>
* xdg-open cannot detect xfce 4.8 correctly (BR33321)
diff --git a/scripts/xdg-screensaver.in b/scripts/xdg-screensaver.in
index 6f2bc1b..ea89dd0 100644
--- a/scripts/xdg-screensaver.in
+++ b/scripts/xdg-screensaver.in
@@ -431,16 +431,18 @@ screensaver_suspend_loop()
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)
@@ -449,7 +451,13 @@ screensaver_gnome_screensaver()
;;
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=$?
;;
@@ -460,18 +468,31 @@ screensaver_gnome_screensaver()
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
;;