Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(133)

Side by Side Diff: third_party/xdg-utils/scripts/xdg-screensaver

Issue 151098: Patch from mdm@google.com... (Closed) Base URL: svn://chrome-svn/chrome/trunk/deps/
Patch Set: Created 11 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
Property Changes:
Name: svn:executable
+ *
OLDNEW
(Empty)
1 #!/bin/sh
2 #---------------------------------------------
3 # xdg-screensaver
4 #
5 # Utility script to control screensaver.
6 #
7 # Refer to the usage() function below for usage.
8 #
9 # Copyright 2006, Bryce Harrington <bryce@osdl.org>
10 #
11 # LICENSE:
12 #
13 # Permission is hereby granted, free of charge, to any person obtaining a
14 # copy of this software and associated documentation files (the "Software"),
15 # to deal in the Software without restriction, including without limitation
16 # the rights to use, copy, modify, merge, publish, distribute, sublicense,
17 # and/or sell copies of the Software, and to permit persons to whom the
18 # Software is furnished to do so, subject to the following conditions:
19 #
20 # The above copyright notice and this permission notice shall be included
21 # in all copies or substantial portions of the Software.
22 #
23 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
24 # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
26 # THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
27 # OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
28 # ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
29 # OTHER DEALINGS IN THE SOFTWARE.
30 #
31 #---------------------------------------------
32
33 manualpage()
34 {
35 cat << _MANUALPAGE
36 Name
37
38 xdg-screensaver - command line tool for controlling the screensaver
39
40 Synopsis
41
42 xdg-screensaver suspend WindowID
43
44 xdg-screensaver resume WindowID
45
46 xdg-screensaver { activate | lock | reset | status }
47
48 xdg-screensaver { --help | --manual | --version }
49
50 Description
51
52 xdg-screensaver provides commands to control the screensaver.
53
54 xdg-screensaver is for use inside a desktop session only. It is not recommended
55 to use xdg-screensaver as root.
56
57 Commands
58
59 suspend WindowID
60
61 Suspends the screensaver and monitor power management. WindowID must be the
62 X Window ID of an existing window of the calling application. The window
63 must remain in existance for the duration of the suspension.
64
65 WindowID can be represented as either a decimal number or as a hexadecimal
66 number consisting of the prefix 0x followed by one or more hexadecimal
67 digits.
68
69 The screensaver can be suspended in relation to multiple windows at the
70 same time. In that case screensaver operation is only restored once the
71 screensaver has been resumed in relation to each of the windows
72
73 resume WindowID
74 Resume the screensaver and monitor power management after being suspended.
75 WindowID must be the same X Window ID that was passed to a previous call of
76 xdg-screensaver suspend
77 activate
78 Turns the screensaver on immediately. This may result in the screen getting
79 locked, depending on existing system policies.
80 lock
81 Lock the screen immediately.
82 reset
83 Turns the screensaver off immediately. If the screen was locked the user
84 may be asked to authenticate first.
85 status
86 Prints enabled to stdout if the screensaver is enabled to turn on after a
87 period of inactivity and prints disabled if the screensaver is not enabled.
88
89 Options
90
91 --help
92 Show command synopsis.
93 --manual
94 Show this manualpage.
95 --version
96 Show the xdg-utils version information.
97
98 Exit Codes
99
100 An exit code of 0 indicates success while a non-zero exit code indicates
101 failure. The following failure codes can be returned:
102
103 1
104 Error in command line syntax.
105 3
106 A required tool could not be found.
107 4
108 The action failed.
109
110 Examples
111
112 xdg-screensaver suspend 0x1c00007
113
114 Causes the screensaver to be disabled till xdg-screensaver resume 0x1c00007 is
115 called. 0x1c00007 must be the X Window ID of an existing window.
116
117 _MANUALPAGE
118 }
119
120 usage()
121 {
122 cat << _USAGE
123 xdg-screensaver - command line tool for controlling the screensaver
124
125 Synopsis
126
127 xdg-screensaver suspend WindowID
128
129 xdg-screensaver resume WindowID
130
131 xdg-screensaver { activate | lock | reset | status }
132
133 xdg-screensaver { --help | --manual | --version }
134
135 _USAGE
136 }
137
138 #@xdg-utils-common@
139
140 #----------------------------------------------------------------------------
141 # Common utility functions included in all XDG wrapper scripts
142 #----------------------------------------------------------------------------
143
144 DEBUG()
145 {
146 [ -z "${XDG_UTILS_DEBUG_LEVEL}" ] && return 0;
147 [ ${XDG_UTILS_DEBUG_LEVEL} -lt $1 ] && return 0;
148 shift
149 echo "$@" >&2
150 }
151
152 #-------------------------------------------------------------
153 # Exit script on successfully completing the desired operation
154
155 exit_success()
156 {
157 if [ $# -gt 0 ]; then
158 echo "$@"
159 echo
160 fi
161
162 exit 0
163 }
164
165
166 #-----------------------------------------
167 # Exit script on malformed arguments, not enough arguments
168 # or missing required option.
169 # prints usage information
170
171 exit_failure_syntax()
172 {
173 if [ $# -gt 0 ]; then
174 echo "xdg-screensaver: $@" >&2
175 echo "Try 'xdg-screensaver --help' for more information." >&2
176 else
177 usage
178 echo "Use 'man xdg-screensaver' or 'xdg-screensaver --manual' for additi onal info."
179 fi
180
181 exit 1
182 }
183
184 #-------------------------------------------------------------
185 # Exit script on missing file specified on command line
186
187 exit_failure_file_missing()
188 {
189 if [ $# -gt 0 ]; then
190 echo "xdg-screensaver: $@" >&2
191 fi
192
193 exit 2
194 }
195
196 #-------------------------------------------------------------
197 # Exit script on failure to locate necessary tool applications
198
199 exit_failure_operation_impossible()
200 {
201 if [ $# -gt 0 ]; then
202 echo "xdg-screensaver: $@" >&2
203 fi
204
205 exit 3
206 }
207
208 #-------------------------------------------------------------
209 # Exit script on failure returned by a tool application
210
211 exit_failure_operation_failed()
212 {
213 if [ $# -gt 0 ]; then
214 echo "xdg-screensaver: $@" >&2
215 fi
216
217 exit 4
218 }
219
220 #------------------------------------------------------------
221 # Exit script on insufficient permission to read a specified file
222
223 exit_failure_file_permission_read()
224 {
225 if [ $# -gt 0 ]; then
226 echo "xdg-screensaver: $@" >&2
227 fi
228
229 exit 5
230 }
231
232 #------------------------------------------------------------
233 # Exit script on insufficient permission to read a specified file
234
235 exit_failure_file_permission_write()
236 {
237 if [ $# -gt 0 ]; then
238 echo "xdg-screensaver: $@" >&2
239 fi
240
241 exit 6
242 }
243
244 check_input_file()
245 {
246 if [ ! -e "$1" ]; then
247 exit_failure_file_missing "file '$1' does not exist"
248 fi
249 if [ ! -r "$1" ]; then
250 exit_failure_file_permission_read "no permission to read file '$1'"
251 fi
252 }
253
254 check_vendor_prefix()
255 {
256 file_label="$2"
257 [ -n "$file_label" ] || file_label="filename"
258 file=`basename "$1"`
259 case "$file" in
260 [a-zA-Z]*-*)
261 return
262 ;;
263 esac
264
265 echo "xdg-screensaver: $file_label '$file' does not have a proper vendor pre fix" >&2
266 echo 'A vendor prefix consists of alpha characters ([a-zA-Z]) and is termina ted' >&2
267 echo 'with a dash ("-"). An example '"$file_label"' is '"'example-$file'" >& 2
268 echo "Use --novendor to override or 'xdg-screensaver --manual' for additiona l info." >&2
269 exit 1
270 }
271
272 check_output_file()
273 {
274 # if the file exists, check if it is writeable
275 # if it does not exists, check if we are allowed to write on the directory
276 if [ -e "$1" ]; then
277 if [ ! -w "$1" ]; then
278 exit_failure_file_permission_write "no permission to write to file ' $1'"
279 fi
280 else
281 DIR=`dirname "$1"`
282 if [ ! -w "$DIR" -o ! -x "$DIR" ]; then
283 exit_failure_file_permission_write "no permission to create file '$1 '"
284 fi
285 fi
286 }
287
288 #----------------------------------------
289 # Checks for shared commands, e.g. --help
290
291 check_common_commands()
292 {
293 while [ $# -gt 0 ] ; do
294 parm="$1"
295 shift
296
297 case "$parm" in
298 --help)
299 usage
300 echo "Use 'man xdg-screensaver' or 'xdg-screensaver --manual' for ad ditional info."
301 exit_success
302 ;;
303
304 --manual)
305 manualpage
306 exit_success
307 ;;
308
309 --version)
310 echo "xdg-screensaver 1.0.1"
311 exit_success
312 ;;
313 esac
314 done
315 }
316
317 check_common_commands "$@"
318
319 [ -z "${XDG_UTILS_DEBUG_LEVEL}" ] && unset XDG_UTILS_DEBUG_LEVEL;
320 if [ ${XDG_UTILS_DEBUG_LEVEL-0} -lt 1 ]; then
321 # Be silent
322 xdg_redirect_output=" > /dev/null 2> /dev/null"
323 else
324 # All output to stderr
325 xdg_redirect_output=" >&2"
326 fi
327
328 #--------------------------------------
329 # Checks for known desktop environments
330 # set variable DE to the desktop environments name, lowercase
331
332 detectDE()
333 {
334 if [ x"$KDE_FULL_SESSION" = x"true" ]; then DE=kde;
335 elif [ x"$GNOME_DESKTOP_SESSION_ID" != x"" ]; then DE=gnome;
336 elif xprop -root _DT_SAVE_MODE | grep ' = \"xfce4\"$' >/dev/null 2>&1; then DE=xfce;
337 fi
338 }
339
340 #----------------------------------------------------------------------------
341 # kfmclient exec/openURL can give bogus exit value in KDE <= 3.5.4
342 # It also always returns 1 in KDE 3.4 and earlier
343 # Simply return 0 in such case
344
345 kfmclient_fix_exit_code()
346 {
347 version=`kde${KDE_SESSION_VERSION}-config --version 2>/dev/null | grep KDE`
348 major=`echo $version | sed 's/KDE: \([0-9]\).*/\1/'`
349 minor=`echo $version | sed 's/KDE: [0-9]*\.\([0-9]\).*/\1/'`
350 release=`echo $version | sed 's/KDE: [0-9]*\.[0-9]*\.\([0-9]\).*/\1/'`
351 test "$major" -gt 3 && return $1
352 test "$minor" -gt 5 && return $1
353 test "$release" -gt 4 && return $1
354 return 0
355 }
356
357 # Check if we can use "mv -T"
358 if mv -T ... ... 2>&1 | grep '\.\.\.' > /dev/null ; then
359 # We can securely move files in /tmp with mv -T
360 DEBUG 1 "mv -T available"
361 MV="mv -T"
362 screensaver_file="/tmp/xdg-screensaver-$USER-"`echo $DISPLAY | sed 's/:/-/g'`
363 else
364 # No secure moves available, use home dir
365 DEBUG 1 "mv -T not available"
366 MV="mv"
367 screensaver_file="$HOME/.xdg-screensaver-"`echo $HOSTNAME-$DISPLAY | sed 's/: /-/g'`
368 fi
369 lockfile_command=`which lockfile 2> /dev/null`
370
371 lockfile()
372 {
373 if [ -n "$lockfile_command" ] ; then
374 $lockfile_command -1 -l 10 -s 3 "$screensaver_file".lock
375 else
376 # Poor man's attempt at doing a lockfile
377 # Be careful not to facilitate a symlink attack
378 local try
379 try=0
380 while ! ln -s "$screensaver_file".lock "$screensaver_file".lock 2> /dev/nul l;
381 do
382 sleep 1
383 try=$(($try+1))
384 if [ $try -eq 3 ] ; then
385 rm -f "$screensaver_file".lock || return # Can't remove lockfile
386 try=0
387 fi
388 done
389 fi
390 }
391
392 unlockfile()
393 {
394 rm -f "$screensaver_file".lock
395 }
396
397 perform_action()
398 {
399 result=1
400
401 if [ "$1" = "resume" ] ; then
402 # Restore DPMS state
403 if [ -f "$screensaver_file.dpms" ]; then
404 rm "$screensaver_file.dpms"
405 # Re-enable DPMS
406 xset +dpms
407 fi
408 fi
409 if [ "$1" = "reset" ] ; then
410 if xset -q | grep 'DPMS is Enabled' > /dev/null 2> /dev/null; then
411 xset dpms force on
412 fi
413 fi
414
415 case "$DE" in
416 kde)
417 screensaver_kde "$1"
418 ;;
419
420 gnome)
421 screensaver_gnome "$1"
422 ;;
423
424 xscreensaver)
425 screensaver_xscreensaver "$1"
426 ;;
427 esac
428
429 if [ "$1" = "suspend" ] ; then
430 # Save DPMS state
431 if xset -q | grep 'DPMS is Enabled' > /dev/null 2> /dev/null; then
432 test "${TMPDIR+set}" = set || TMPDIR=/tmp
433 tmpfile=`mktemp $TMPDIR/tmp.XXXXXXXXXX`
434 $MV "$tmpfile" "$screensaver_file.dpms"
435 # Disable DPMS
436 xset -dpms
437 fi
438 fi
439
440 }
441
442 cleanup_suspend()
443 {
444 lockfile
445 test "${TMPDIR+set}" = set || TMPDIR=/tmp
446 tmpfile=`mktemp $TMPDIR/tmp.XXXXXXXXXX`
447 grep -v "$window_id:" "$screensaver_file" > "$tmpfile" 2> /dev/null
448 $MV "$tmpfile" "$screensaver_file"
449 if [ ! -s "$screensaver_file" ] ; then
450 rm "$screensaver_file"
451 unlockfile
452 # $screensaver_file is empty, do resume
453 perform_action resume
454 else
455 unlockfile
456 fi
457 }
458
459 do_resume()
460 {
461 lockfile # Obtain lockfile
462 # Find the PID of the trackingprocess
463 xprop_pid=`grep "$window_id:" "$screensaver_file" 2> /dev/null | cut -d ':' -f 2`
464 unlockfile # Free lockfile
465 if [ -n "$xprop_pid" ] && ps -p "$xprop_pid" 2> /dev/null | grep xprop > /dev/ null; then
466 # Kill the tracking process
467 kill -TERM $xprop_pid
468 fi
469 cleanup_suspend
470 }
471
472 XPROP=`which xprop 2> /dev/null`
473
474 check_window_id()
475 {
476 if [ -z "$XPROP" ]; then
477 DEBUG 3 "xprop not found"
478 return
479 fi
480 DEBUG 2 "Running $XPROP -id $window_id"
481 if $XPROP -id $window_id > /dev/null 2> /dev/null; then
482 DEBUG 3 Window $window_id exists
483 else
484 DEBUG 3 Window $window_id does not exist
485 exit_failure_operation_failed "Window $window_id does not exist"
486 fi
487 }
488
489 track_window()
490 {
491 if [ -z "$XPROP" ]; then
492 # Don't track window if we don't have xprop
493 return
494 fi
495 lockfile
496
497 test "${TMPDIR+set}" = set || TMPDIR=/tmp
498 tmpfile=`mktemp $TMPDIR/tmp.XXXXXXXXXX`
499 # Filter stale entries from the xdg-screensaver status file
500 # Return if $window_id is being tracked already
501 (
502 already_tracked=1
503 IFS_save="$IFS"
504 IFS=":"
505 while read wid pid; do
506 if ps -p "$pid" 2> /dev/null | grep xprop > /dev/null; then
507 echo "$wid:$pid"
508 if [ $wid = $window_id ] ; then
509 already_tracked=0
510 fi
511 fi
512 done
513 IFS="$IFS_save"
514 exit $already_tracked
515 ) < $screensaver_file > $tmpfile
516 already_tracked=$?
517
518 if [ "$already_tracked" -eq "0" ] ; then
519 $MV "$tmpfile" "$screensaver_file"
520 # We are already tracking $window_id, don't do anything
521 unlockfile
522 return
523 fi
524
525 # Start tracking $window_id
526 $XPROP -id $window_id -spy > /dev/null &
527 xprop_pid=$!
528 # Add window_id and xprop_pid to the xdg-screensave status file
529 echo "$window_id:$xprop_pid" >> $tmpfile
530 $MV "$tmpfile" "$screensaver_file"
531 unlockfile
532 # Wait for xprop to edit, it means that the window disappeared
533 wait $xprop_pid
534 # Clean up the administration and resume the screensaver
535 cleanup_suspend
536 }
537
538 screensaver_freedesktop()
539 {
540 case "$1" in
541 suspend)
542 #FIXME (get/store cookie)
543 qdbus org.freedesktop.ScreenSaver /ScreenSaver org.freedesktop.ScreenSav er.Inhibit $window_id xdg-screensaver > /dev/null
544 result=$?
545 ;;
546
547 resume)
548 qdbus org.freedesktop.ScreenSaver /ScreenSaver org.freedesktop.ScreenSav er.SetActive true > /dev/null
549 result=$?
550 ;;
551
552 activate)
553 qdbus org.freedesktop.ScreenSaver /ScreenSaver org.freedesktop.ScreenSav er.SetActive true > /dev/null
554 result=$?
555 ;;
556
557 lock)
558 qdbus org.freedesktop.ScreenSaver /ScreenSaver org.freedesktop.ScreenSav er.Lock > /dev/null
559 ;;
560
561 reset)
562 #FIXME (cookies?)
563 qdbus org.freedesktop.ScreenSaver /ScreenSaver org.freedesktop.ScreenSav er.UnInhibit $window_id > /dev/null
564 result=$?
565 ;;
566
567 status)
568 status=`qdbus org.freedesktop.ScreenSaver /ScreenSaver org.freedesktop.S creenSaver.GetActive`
569 result=$?
570 if [ x"$status" = "xtrue" ]; then
571 echo "enabled"
572 elif [ x"$status" = "xfalse" ]; then
573 echo "disabled"
574 else
575 echo "ERROR: dbus org.freedesktop.ScreenSaver.GetActive returned '$s tatus'" >&2
576 return 1
577 fi
578 ;;
579
580 *)
581 echo "ERROR: Unknown command '$1'" >&2
582 return 1
583 ;;
584 esac
585 }
586
587 screensaver_kde()
588 {
589 case "$1" in
590 suspend)
591 dcop kdesktop KScreensaverIface enable false > /dev/null
592 result=$?
593 ;;
594
595 resume)
596 dcop kdesktop KScreensaverIface configure > /dev/null
597 result=$?
598 ;;
599
600 activate)
601 dcop kdesktop KScreensaverIface save > /dev/null
602 result=$?
603 ;;
604
605 lock)
606 dcop kdesktop KScreensaverIface lock > /dev/null
607 result=$?
608 ;;
609
610 reset)
611 # Turns the screensaver off right now
612 dcop kdesktop KScreensaverIface quit > /dev/null
613 result=$?
614 ;;
615
616 status)
617 status=`dcop kdesktop KScreensaverIface isEnabled`
618 result=$?
619 if [ x"$status" = "xtrue" ]; then
620 echo "enabled"
621 elif [ x"$status" = "xfalse" ]; then
622 echo "disabled"
623 else
624 echo "ERROR: kdesktop KScreensaverIface isEnabled returned '$status '" >&2
625 return 1
626 fi
627 ;;
628
629 *)
630 echo "ERROR: Unknown command '$1'" >&2
631 return 1
632 ;;
633 esac
634 }
635
636 screensaver_suspend_loop()
637 {
638 lockfile
639 test "${TMPDIR+set}" = set || TMPDIR=/tmp
640 tmpfile=`mktemp $TMPDIR/tmp.XXXXXXXXXX`
641 # Filter stale entries from the xdg-screensaver status file
642 cat "$screensaver_file" 2> /dev/null | (
643 IFS_save="$IFS"
644 IFS=":"
645 while read wid pid; do
646 if ps -p "$pid" 2> /dev/null | grep xprop > /dev/null; then
647 echo "$wid:$pid"
648 fi
649 done
650 IFS="$IFS_save"
651 ) > $tmpfile
652 if [ -s "$tmpfile" ] ; then
653 # Suspend pending, don't do a thing
654 $MV "$tmpfile" "$screensaver_file"
655 unlockfile
656 return
657 fi
658 $MV "$tmpfile" "$screensaver_file"
659 unlockfile
660 (while [ -f "$screensaver_file" ]; do $*; sleep 59; done) > /dev/null 2> /dev/ null &
661 }
662
663 screensaver_gnome()
664 {
665 # TODO
666 # There seems to be a DBUS interface for gnome-screensaver
667 # See http://lists.mplayerhq.hu/pipermail/mplayer-dev-eng/2006-April/042579.html and
668 # http://cvs.gnome.org/viewcvs/gnome-screensaver/src/gs-listener-dbus.c?rev=1.36 &view=log
669 # A problem seems to be that Inhibit is tied to the lifetime of the DBUS appname and
670 # this can not be used from a script
671 case "$1" in
672 suspend)
673 screensaver_suspend_loop gnome-screensaver-command --poke
674 result=0
675 ;;
676
677 resume)
678 # Automatic resume when $screensaver_file disappears
679 result=0
680 ;;
681
682 activate)
683 gnome-screensaver-command --activate > /dev/null 2> /dev/null
684 result=$?
685 ;;
686
687 lock)
688 gnome-screensaver-command --lock > /dev/null 2> /dev/null
689 result=$?
690 ;;
691
692 reset)
693 # Turns the screensaver off right now
694 gnome-screensaver-command --deactivate > /dev/null 2> /dev/null
695 result=$?
696 ;;
697
698 status)
699 result=0
700 if [ -f "$screensaver_file" ] ; then
701 echo "disabled"
702 elif gnome-screensaver-command --query > /dev/null 2> /dev/null; then
703 echo "enabled"
704 else
705 # Something is wrong
706 echo "disabled"
707 fi
708 ;;
709
710 *)
711 echo "ERROR: Unknown command '$1" >&2
712 return 1
713 ;;
714 esac
715 }
716
717 screensaver_xscreensaver()
718 {
719 case "$1" in
720 suspend)
721 screensaver_suspend_loop xscreensaver-command -deactivate
722 result=0
723 ;;
724
725 resume)
726 # Automatic resume when $screensaver_file disappears
727 result=0
728 ;;
729
730 activate)
731 xscreensaver-command -activate > /dev/null 2> /dev/null
732 result=$?
733 ;;
734
735 lock)
736 xscreensaver-command -lock > /dev/null 2> /dev/null
737 result=$?
738 ;;
739
740 reset)
741 # Turns the screensaver off right now
742 xscreensaver-command -deactivate > /dev/null 2> /dev/null
743 result=$?
744 ;;
745
746 status)
747 result=0
748 if [ -f "$screensaver_file" ] ; then
749 echo "disabled"
750 else
751 echo "enabled"
752 fi
753 ;;
754
755 *)
756 echo "ERROR: Unknown command '$1" >&2
757 return 1
758 ;;
759 esac
760 }
761
762 [ x"$1" != x"" ] || exit_failure_syntax
763
764 action=
765 window_id=
766
767 case $1 in
768 suspend)
769 action="$1"
770
771 shift
772
773 if [ -z "$1" ] ; then
774 exit_failure_syntax "WindowID argument missing"
775 fi
776
777 window_id="$1"
778 check_window_id
779 ;;
780
781 resume)
782 action="$1"
783
784 shift
785
786 if [ -z "$1" ] ; then
787 exit_failure_syntax "WindowID argument missing"
788 fi
789
790 window_id="$1"
791 check_window_id
792 ;;
793
794 activate)
795 action="$1"
796 ;;
797
798 lock)
799 action="$1"
800 ;;
801
802 reset)
803 action="$1"
804 ;;
805
806 status)
807 action="$1"
808 ;;
809
810 *)
811 exit_failure_syntax "unknown command '$1'"
812 ;;
813 esac
814
815 detectDE
816 # Consider "xscreensaver" a separate DE
817 xscreensaver-command -version 2> /dev/null | grep XScreenSaver > /dev/null && DE ="xscreensaver"
818
819 if [ "$action" = "resume" ] ; then
820 do_resume
821 exit_success
822 fi
823
824 perform_action "$action"
825
826 if [ "$action" = "suspend" ] ; then
827 # Start tracking $window_id and resume the screensaver once it disappears
828 ( track_window ) 2> /dev/null > /dev/null &
829 fi
830
831 if [ $result -eq 0 ]; then
832 exit_success
833 else
834 exit_failure_operation_failed
835 fi
OLDNEW
« no previous file with comments | « third_party/xdg-utils/scripts/xdg-open.in ('k') | third_party/xdg-utils/scripts/xdg-screensaver.in » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698