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

« back to all changes in this revision

Viewing changes to scripts/xdg-screensaver

  • 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:
809
809
 
810
810
screensaver_gnome_screensaver()
811
811
{
812
 
# TODO
813
 
# There seems to be a DBUS interface for gnome-screensaver
814
 
# See http://lists.mplayerhq.hu/pipermail/mplayer-dev-eng/2006-April/042579.html and
815
 
# http://cvs.gnome.org/viewcvs/gnome-screensaver/src/gs-listener-dbus.c?rev=1.36&view=log
816
 
# A problem seems to be that Inhibit is tied to the lifetime of the DBUS appname and
817
 
# this can not be used from a script
 
812
# DBUS interface for gnome-screensaver
 
813
# http://people.gnome.org/~mccann/gnome-screensaver/docs/gnome-screensaver.html
818
814
    case "$1" in
819
815
        suspend)
820
 
        screensaver_suspend_loop gnome-screensaver-command --poke
821
 
        result=0
 
816
        screensaver_suspend_loop \
 
817
        dbus-send --session \
 
818
                  --dest=org.gnome.ScreenSaver \
 
819
                  --type=method_call \
 
820
                  /org/gnome/ScreenSaver \
 
821
                  org.gnome.ScreenSaver.SimulateUserActivity \
 
822
                  2> /dev/null
 
823
        result=$?
822
824
        ;;
823
825
 
824
826
        resume)
827
829
        ;;
828
830
 
829
831
        activate)
830
 
        gnome-screensaver-command --activate > /dev/null 2> /dev/null
 
832
        dbus-send --session \
 
833
                  --dest=org.gnome.ScreenSaver \
 
834
                  --type=method_call \
 
835
                  /org/gnome/ScreenSaver \
 
836
                  org.gnome.ScreenSaver.SetActive \
 
837
                  boolean:true \
 
838
                  2> /dev/null
831
839
        result=$?
832
840
        ;;
833
841
 
838
846
 
839
847
        reset)
840
848
        # Turns the screensaver off right now
841
 
        gnome-screensaver-command --deactivate > /dev/null 2> /dev/null
 
849
        dbus-send --session \
 
850
                  --dest=org.gnome.ScreenSaver \
 
851
                  --type=method_call \
 
852
                  /org/gnome/ScreenSaver \
 
853
                  org.gnome.ScreenSaver.SimulateUserActivity \
 
854
                 2> /dev/null
842
855
        result=$?
843
856
        ;;
844
857
 
845
858
        status)
846
 
        result=0
847
 
        if [ -f "$screensaver_file" ] ; then
848
 
            echo "disabled"
849
 
        elif gnome-screensaver-command --query > /dev/null 2> /dev/null; then
 
859
        status=`dbus-send --session \
 
860
                          --dest=org.gnome.ScreenSaver \
 
861
                          --type=method_call \
 
862
                          --print-reply \
 
863
                          --reply-timeout=2000 \
 
864
                          /org/gnome/ScreenSaver \
 
865
                          org.gnome.ScreenSaver.GetActive \
 
866
                          | grep boolean | cut -d ' ' -f 5`
 
867
        result=$?
 
868
        if [ x"$status" = "xtrue" -o x"$status" = "xfalse" ]; then
850
869
            echo "enabled"
 
870
        elif [ x"$result" != "x0" ]; then
 
871
            echo "ERROR: dbus org.gnome.ScreenSaver.GetActive returned '$status'" >&2
 
872
            return 1
851
873
        else
852
 
            # Something is wrong
853
874
            echo "disabled"
854
875
        fi
855
876
        ;;