Merge lp:~thad-fisch-deactivatedaccount/ubuntu/vivid/xdg-utils/lp1363540 into lp:ubuntu/vivid/xdg-utils

Proposed by Thaddaeus Tintenfisch on 2015-01-17
Status: Merged
Approved by: Didier Roche on 2015-01-22
Approved revision: 27
Merge reported by: Didier Roche
Merged at revision: not available
Proposed branch: lp:~thad-fisch-deactivatedaccount/ubuntu/vivid/xdg-utils/lp1363540
Merge into: lp:ubuntu/vivid/xdg-utils
Diff against target: 1217 lines (+1030/-115)
6 files modified
.pc/applied-patches (+1/-0)
.pc/xdg-screensaver-restore-timeout.diff/scripts/xdg-screensaver (+962/-0)
debian/patches/series (+1/-1)
debian/patches/xdg-screensaver-restore-timeout.diff (+50/-0)
debian/patches/xserver-blanking.diff (+0/-68)
scripts/xdg-screensaver (+16/-46)
To merge this branch: bzr merge lp:~thad-fisch-deactivatedaccount/ubuntu/vivid/xdg-utils/lp1363540
Reviewer Review Type Date Requested Status
Didier Roche 2015-01-19 Approve on 2015-01-22
Simon SteinbeiƟ (community) 2015-01-17 Approve on 2015-01-19
Review via email: mp+246820@code.launchpad.net

Description of the change

This merge-request adds a patch which fixes a small issue in the xdg-screensaver resume functionality. Calling xdg-screensaver resume should restore the X11 screensaver timeout properly and not just fall back to the default timeout.

The patch has not been reviewed or applied upstream yet, but it was tested and works fine.

https://bugs.freedesktop.org/show_bug.cgi?id=88210

To post a comment you must log in.
Simon SteinbeiƟ (ochosi) wrote :

I've previously tested the patch, re-tested with this branch and can approve with my Xubuntu Project Lead hat on.

review: Approve
Daniel Holbach (dholbach) wrote :

Just pointing out: this request has lp:~ochosi/ubuntu/vivid/xdg-utils/drop_xserver_patch already merged.

Didier Roche (didrocks) wrote :

Thanks for looking at this bug and help to make ubuntu better!
Your patch looks good and makes sense, I'm releasing with the 2 merges (the other one wasn't merged in mainline yet).

Sponsoring now!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file '.pc/applied-patches'
2--- .pc/applied-patches 2014-07-16 09:20:59 +0000
3+++ .pc/applied-patches 2015-01-17 16:43:41 +0000
4@@ -12,3 +12,4 @@
5 lp779156-lubuntu.diff
6 xdg-screensaver-dbus.patch
7 xfce-blanking.diff
8+xdg-screensaver-restore-timeout.diff
9
10=== added directory '.pc/xdg-screensaver-restore-timeout.diff'
11=== added file '.pc/xdg-screensaver-restore-timeout.diff/.timestamp'
12=== added directory '.pc/xdg-screensaver-restore-timeout.diff/scripts'
13=== added file '.pc/xdg-screensaver-restore-timeout.diff/scripts/xdg-screensaver'
14--- .pc/xdg-screensaver-restore-timeout.diff/scripts/xdg-screensaver 1970-01-01 00:00:00 +0000
15+++ .pc/xdg-screensaver-restore-timeout.diff/scripts/xdg-screensaver 2015-01-17 16:43:41 +0000
16@@ -0,0 +1,962 @@
17+#!/bin/sh
18+#---------------------------------------------
19+# xdg-screensaver
20+#
21+# Utility script to control screensaver.
22+#
23+# Refer to the usage() function below for usage.
24+#
25+# Copyright 2006, Bryce Harrington <bryce@osdl.org>
26+#
27+# LICENSE:
28+#
29+# Permission is hereby granted, free of charge, to any person obtaining a
30+# copy of this software and associated documentation files (the "Software"),
31+# to deal in the Software without restriction, including without limitation
32+# the rights to use, copy, modify, merge, publish, distribute, sublicense,
33+# and/or sell copies of the Software, and to permit persons to whom the
34+# Software is furnished to do so, subject to the following conditions:
35+#
36+# The above copyright notice and this permission notice shall be included
37+# in all copies or substantial portions of the Software.
38+#
39+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
40+# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
41+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
42+# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
43+# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
44+# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
45+# OTHER DEALINGS IN THE SOFTWARE.
46+#
47+#---------------------------------------------
48+
49+manualpage()
50+{
51+cat << _MANUALPAGE
52+Name
53+
54+xdg-screensaver - command line tool for controlling the screensaver
55+
56+Synopsis
57+
58+xdg-screensaver suspend WindowID
59+
60+xdg-screensaver resume WindowID
61+
62+xdg-screensaver { activate | lock | reset | status }
63+
64+xdg-screensaver { --help | --manual | --version }
65+
66+Description
67+
68+xdg-screensaver provides commands to control the screensaver.
69+
70+xdg-screensaver is for use inside a desktop session only. It is not recommended
71+to use xdg-screensaver as root.
72+
73+Commands
74+
75+suspend WindowID
76+
77+ Suspends the screensaver and monitor power management. WindowID must be the
78+ X Window ID of an existing window of the calling application. The window
79+ must remain in existance for the duration of the suspension.
80+
81+ WindowID can be represented as either a decimal number or as a hexadecimal
82+ number consisting of the prefix 0x followed by one or more hexadecimal
83+ digits.
84+
85+ The screensaver can be suspended in relation to multiple windows at the
86+ same time. In that case screensaver operation is only restored once the
87+ screensaver has been resumed in relation to each of the windows
88+
89+resume WindowID
90+ Resume the screensaver and monitor power management after being suspended.
91+ WindowID must be the same X Window ID that was passed to a previous call of
92+ xdg-screensaver suspend
93+activate
94+ Turns the screensaver on immediately. This may result in the screen getting
95+ locked, depending on existing system policies.
96+lock
97+ Lock the screen immediately.
98+reset
99+ Turns the screensaver off immediately. If the screen was locked the user
100+ may be asked to authenticate first.
101+status
102+ Prints enabled to stdout if the screensaver is enabled to turn on after a
103+ period of inactivity and prints disabled if the screensaver is not enabled.
104+
105+Options
106+
107+--help
108+ Show command synopsis.
109+--manual
110+ Show this manualpage.
111+--version
112+ Show the xdg-utils version information.
113+
114+Exit Codes
115+
116+An exit code of 0 indicates success while a non-zero exit code indicates
117+failure. The following failure codes can be returned:
118+
119+1
120+ Error in command line syntax.
121+3
122+ A required tool could not be found.
123+4
124+ The action failed.
125+
126+Examples
127+
128+xdg-screensaver suspend 0x1c00007
129+
130+Causes the screensaver to be disabled till xdg-screensaver resume 0x1c00007 is
131+called. 0x1c00007 must be the X Window ID of an existing window.
132+
133+_MANUALPAGE
134+}
135+
136+usage()
137+{
138+cat << _USAGE
139+xdg-screensaver - command line tool for controlling the screensaver
140+
141+Synopsis
142+
143+xdg-screensaver suspend WindowID
144+
145+xdg-screensaver resume WindowID
146+
147+xdg-screensaver { activate | lock | reset | status }
148+
149+xdg-screensaver { --help | --manual | --version }
150+
151+_USAGE
152+}
153+
154+#@xdg-utils-common@
155+
156+#----------------------------------------------------------------------------
157+# Common utility functions included in all XDG wrapper scripts
158+#----------------------------------------------------------------------------
159+
160+DEBUG()
161+{
162+ [ -z "${XDG_UTILS_DEBUG_LEVEL}" ] && return 0;
163+ [ ${XDG_UTILS_DEBUG_LEVEL} -lt $1 ] && return 0;
164+ shift
165+ echo "$@" >&2
166+}
167+
168+#-------------------------------------------------------------
169+# Exit script on successfully completing the desired operation
170+
171+exit_success()
172+{
173+ if [ $# -gt 0 ]; then
174+ echo "$@"
175+ echo
176+ fi
177+
178+ exit 0
179+}
180+
181+
182+#-----------------------------------------
183+# Exit script on malformed arguments, not enough arguments
184+# or missing required option.
185+# prints usage information
186+
187+exit_failure_syntax()
188+{
189+ if [ $# -gt 0 ]; then
190+ echo "xdg-screensaver: $@" >&2
191+ echo "Try 'xdg-screensaver --help' for more information." >&2
192+ else
193+ usage
194+ echo "Use 'man xdg-screensaver' or 'xdg-screensaver --manual' for additional info."
195+ fi
196+
197+ exit 1
198+}
199+
200+#-------------------------------------------------------------
201+# Exit script on missing file specified on command line
202+
203+exit_failure_file_missing()
204+{
205+ if [ $# -gt 0 ]; then
206+ echo "xdg-screensaver: $@" >&2
207+ fi
208+
209+ exit 2
210+}
211+
212+#-------------------------------------------------------------
213+# Exit script on failure to locate necessary tool applications
214+
215+exit_failure_operation_impossible()
216+{
217+ if [ $# -gt 0 ]; then
218+ echo "xdg-screensaver: $@" >&2
219+ fi
220+
221+ exit 3
222+}
223+
224+#-------------------------------------------------------------
225+# Exit script on failure returned by a tool application
226+
227+exit_failure_operation_failed()
228+{
229+ if [ $# -gt 0 ]; then
230+ echo "xdg-screensaver: $@" >&2
231+ fi
232+
233+ exit 4
234+}
235+
236+#------------------------------------------------------------
237+# Exit script on insufficient permission to read a specified file
238+
239+exit_failure_file_permission_read()
240+{
241+ if [ $# -gt 0 ]; then
242+ echo "xdg-screensaver: $@" >&2
243+ fi
244+
245+ exit 5
246+}
247+
248+#------------------------------------------------------------
249+# Exit script on insufficient permission to write a specified file
250+
251+exit_failure_file_permission_write()
252+{
253+ if [ $# -gt 0 ]; then
254+ echo "xdg-screensaver: $@" >&2
255+ fi
256+
257+ exit 6
258+}
259+
260+check_input_file()
261+{
262+ if [ ! -e "$1" ]; then
263+ exit_failure_file_missing "file '$1' does not exist"
264+ fi
265+ if [ ! -r "$1" ]; then
266+ exit_failure_file_permission_read "no permission to read file '$1'"
267+ fi
268+}
269+
270+check_vendor_prefix()
271+{
272+ file_label="$2"
273+ [ -n "$file_label" ] || file_label="filename"
274+ file=`basename "$1"`
275+ case "$file" in
276+ [a-zA-Z]*-*)
277+ return
278+ ;;
279+ esac
280+
281+ echo "xdg-screensaver: $file_label '$file' does not have a proper vendor prefix" >&2
282+ echo 'A vendor prefix consists of alpha characters ([a-zA-Z]) and is terminated' >&2
283+ echo 'with a dash ("-"). An example '"$file_label"' is '"'example-$file'" >&2
284+ echo "Use --novendor to override or 'xdg-screensaver --manual' for additional info." >&2
285+ exit 1
286+}
287+
288+check_output_file()
289+{
290+ # if the file exists, check if it is writeable
291+ # if it does not exists, check if we are allowed to write on the directory
292+ if [ -e "$1" ]; then
293+ if [ ! -w "$1" ]; then
294+ exit_failure_file_permission_write "no permission to write to file '$1'"
295+ fi
296+ else
297+ DIR=`dirname "$1"`
298+ if [ ! -w "$DIR" -o ! -x "$DIR" ]; then
299+ exit_failure_file_permission_write "no permission to create file '$1'"
300+ fi
301+ fi
302+}
303+
304+#----------------------------------------
305+# Checks for shared commands, e.g. --help
306+
307+check_common_commands()
308+{
309+ while [ $# -gt 0 ] ; do
310+ parm="$1"
311+ shift
312+
313+ case "$parm" in
314+ --help)
315+ usage
316+ echo "Use 'man xdg-screensaver' or 'xdg-screensaver --manual' for additional info."
317+ exit_success
318+ ;;
319+
320+ --manual)
321+ manualpage
322+ exit_success
323+ ;;
324+
325+ --version)
326+ echo "xdg-screensaver 1.0.2"
327+ exit_success
328+ ;;
329+ esac
330+ done
331+}
332+
333+check_common_commands "$@"
334+
335+[ -z "${XDG_UTILS_DEBUG_LEVEL}" ] && unset XDG_UTILS_DEBUG_LEVEL;
336+if [ ${XDG_UTILS_DEBUG_LEVEL-0} -lt 1 ]; then
337+ # Be silent
338+ xdg_redirect_output=" > /dev/null 2> /dev/null"
339+else
340+ # All output to stderr
341+ xdg_redirect_output=" >&2"
342+fi
343+
344+#--------------------------------------
345+# Checks for known desktop environments
346+# set variable DE to the desktop environments name, lowercase
347+
348+detectDE()
349+{
350+ if [ x"$KDE_FULL_SESSION" = x"true" ]; then DE=kde;
351+ elif [ x"$GNOME_DESKTOP_SESSION_ID" != x"" ]; then DE=gnome;
352+ elif `dbus-send --print-reply --dest=org.freedesktop.DBus /org/freedesktop/DBus org.freedesktop.DBus.GetNameOwner string:org.gnome.SessionManager > /dev/null 2>&1` ; then DE=gnome;
353+ elif xprop -root _DT_SAVE_MODE 2> /dev/null | grep ' = \"xfce4\"$' >/dev/null 2>&1; then DE=xfce;
354+ elif [ x"$DESKTOP_SESSION" = x"LXDE" ]; then DE=lxde;
355+ else DE=""
356+ fi
357+}
358+
359+#----------------------------------------------------------------------------
360+# kfmclient exec/openURL can give bogus exit value in KDE <= 3.5.4
361+# It also always returns 1 in KDE 3.4 and earlier
362+# Simply return 0 in such case
363+
364+kfmclient_fix_exit_code()
365+{
366+ version=`kde${KDE_SESSION_VERSION}-config --version 2>/dev/null | grep '^KDE'`
367+ major=`echo $version | sed 's/KDE.*: \([0-9]\).*/\1/'`
368+ minor=`echo $version | sed 's/KDE.*: [0-9]*\.\([0-9]\).*/\1/'`
369+ release=`echo $version | sed 's/KDE.*: [0-9]*\.[0-9]*\.\([0-9]\).*/\1/'`
370+ test "$major" -gt 3 && return $1
371+ test "$minor" -gt 5 && return $1
372+ test "$release" -gt 4 && return $1
373+ return 0
374+}
375+
376+# Check if we can use "mv -T"
377+if mv -T ... ... 2>&1 | grep '\.\.\.' > /dev/null ; then
378+ # We can securely move files in /tmp with mv -T
379+ DEBUG 1 "mv -T available"
380+ MV="mv -T"
381+ screensaver_file="/tmp/xdg-screensaver-$USER-"`echo $DISPLAY | sed 's/:/-/g'`
382+else
383+ # No secure moves available, use home dir
384+ DEBUG 1 "mv -T not available"
385+ MV="mv"
386+ screensaver_file="$HOME/.xdg-screensaver-"`echo $(hostname)-$DISPLAY | sed 's/:/-/g'`
387+fi
388+lockfile_command=`which lockfile 2> /dev/null`
389+
390+lockfile()
391+{
392+ if [ -n "$lockfile_command" ] ; then
393+ $lockfile_command -1 -l 10 -s 3 "$screensaver_file".lock
394+ else
395+ # Poor man's attempt at doing a lockfile
396+ # Be careful not to facilitate a symlink attack
397+ local try
398+ try=0
399+ while ! ln -s "$screensaver_file".lock "$screensaver_file".lock 2> /dev/null;
400+ do
401+ sleep 1
402+ try=$(($try+1))
403+ if [ $try -eq 3 ] ; then
404+ rm -f "$screensaver_file".lock || return # Can't remove lockfile
405+ try=0
406+ fi
407+ done
408+ fi
409+}
410+
411+unlockfile()
412+{
413+ rm -f "$screensaver_file".lock
414+}
415+
416+perform_action()
417+{
418+ result=1
419+
420+ if [ "$1" = "resume" ] ; then
421+ # Restore DPMS state
422+ if [ -f "$screensaver_file.dpms" ]; then
423+ rm "$screensaver_file.dpms"
424+ # Re-enable DPMS
425+ xset +dpms
426+ fi
427+ fi
428+ if [ "$1" = "reset" ] ; then
429+ if xset -q | grep 'DPMS is Enabled' > /dev/null 2> /dev/null; then
430+ xset dpms force on
431+ fi
432+ fi
433+
434+ case "$DE" in
435+ kde)
436+ if [ x"$KDE_SESSION_VERSION" = x"4" ]; then
437+ screensaver_freedesktop "$1"
438+ else
439+ screensaver_kde "$1"
440+ fi
441+ ;;
442+
443+ gnome_screensaver)
444+ screensaver_gnome_screensaver "$1"
445+ ;;
446+
447+ xscreensaver)
448+ screensaver_xscreensaver "$1"
449+ ;;
450+
451+ xfce)
452+ screensaver_xserver "$1"
453+ ;;
454+
455+ '')
456+ screensaver_xserver "$1"
457+ ;;
458+ esac
459+
460+ if [ "$1" = "suspend" ] ; then
461+ # Save DPMS state
462+ if xset -q | grep 'DPMS is Enabled' > /dev/null 2> /dev/null; then
463+ test "${TMPDIR+set}" = set || TMPDIR=/tmp
464+ tmpfile=`mktemp $TMPDIR/tmp.XXXXXXXXXX`
465+ $MV "$tmpfile" "$screensaver_file.dpms"
466+ # Disable DPMS
467+ xset -dpms
468+ fi
469+ fi
470+
471+}
472+
473+cleanup_suspend()
474+{
475+ lockfile
476+ test "${TMPDIR+set}" = set || TMPDIR=/tmp
477+ tmpfile=`mktemp $TMPDIR/tmp.XXXXXXXXXX`
478+ grep -v "$window_id:$xprop_pid\$" "$screensaver_file" > "$tmpfile" 2> /dev/null
479+ $MV "$tmpfile" "$screensaver_file"
480+ if [ ! -s "$screensaver_file" ] ; then
481+ rm "$screensaver_file"
482+ unlockfile
483+ # $screensaver_file is empty, do resume
484+ perform_action resume
485+ else
486+ unlockfile
487+ fi
488+}
489+
490+do_resume()
491+{
492+ lockfile # Obtain lockfile
493+ # Find the PID of the trackingprocess
494+ xprop_pid=`grep "$window_id:" "$screensaver_file" 2> /dev/null | cut -d ':' -f 2`
495+ unlockfile # Free lockfile
496+ if [ -n "$xprop_pid" ] && ps -p "$xprop_pid" 2> /dev/null | grep xprop > /dev/null; then
497+ # Kill the tracking process
498+ kill -s TERM $xprop_pid
499+ fi
500+ cleanup_suspend
501+}
502+
503+XPROP=`which xprop 2> /dev/null`
504+
505+check_window_id()
506+{
507+ if [ -z "$XPROP" ]; then
508+ DEBUG 3 "xprop not found"
509+ return
510+ fi
511+ DEBUG 2 "Running $XPROP -id $window_id"
512+ if $XPROP -id $window_id > /dev/null 2> /dev/null; then
513+ DEBUG 3 Window $window_id exists
514+ else
515+ DEBUG 3 Window $window_id does not exist
516+ exit_failure_operation_failed "Window $window_id does not exist"
517+ fi
518+}
519+
520+track_window()
521+{
522+ if [ -z "$XPROP" ]; then
523+ # Don't track window if we don't have xprop
524+ return
525+ fi
526+ lockfile
527+
528+ test "${TMPDIR+set}" = set || TMPDIR=/tmp
529+ tmpfile=`mktemp $TMPDIR/tmp.XXXXXXXXXX`
530+ # Filter stale entries from the xdg-screensaver status file
531+ # Return if $window_id is being tracked already
532+ (
533+ already_tracked=1
534+ IFS_save="$IFS"
535+ IFS=":"
536+ while read wid pid; do
537+ if ps -p "$pid" 2> /dev/null | grep xprop > /dev/null; then
538+ echo "$wid:$pid"
539+ if [ $wid = $window_id ] ; then
540+ already_tracked=0
541+ fi
542+ fi
543+ done
544+ IFS="$IFS_save"
545+ exit $already_tracked
546+ ) < $screensaver_file > $tmpfile
547+ already_tracked=$?
548+
549+ if [ "$already_tracked" -eq "0" ] ; then
550+ $MV "$tmpfile" "$screensaver_file"
551+ # We are already tracking $window_id, don't do anything
552+ unlockfile
553+ return
554+ fi
555+
556+ # Start tracking $window_id
557+ $XPROP -id $window_id -spy > /dev/null &
558+ xprop_pid=$!
559+ # Add window_id and xprop_pid to the xdg-screensave status file
560+ echo "$window_id:$xprop_pid" >> $tmpfile
561+ $MV "$tmpfile" "$screensaver_file"
562+ unlockfile
563+ # Wait for xprop to edit, it means that the window disappeared
564+ wait $xprop_pid
565+ # Clean up the administration and resume the screensaver
566+ cleanup_suspend
567+}
568+
569+screensaver_freedesktop()
570+{
571+ case "$1" in
572+ suspend)
573+ dbus-send --session \
574+ --dest=org.freedesktop.ScreenSaver \
575+ --type=method_call \
576+ --print-reply \
577+ --reply-timeout=2000 \
578+ /ScreenSaver \
579+ org.freedesktop.ScreenSaver.Inhibit \
580+ string:$window_id \
581+ string:xdg-screensaver \
582+ | grep uint32 | cut -d ' ' -f 5 >| "$screensaver_file.cookie" \
583+ 2> /dev/null
584+ result=$?
585+ ;;
586+
587+ resume)
588+ if [ -f "$screensaver_file.cookie" ] ; then
589+ value=`cat "$screensaver_file.cookie"`
590+ dbus-send --session \
591+ --dest=org.freedesktop.ScreenSaver \
592+ --type=method_call \
593+ /ScreenSaver \
594+ org.freedesktop.ScreenSaver.UnInhibit \
595+ uint32:$value \
596+ 2> /dev/null
597+ rm -f "$screensaver_file.cookie"
598+ fi
599+ result=$?
600+ ;;
601+
602+ activate)
603+ dbus-send --session \
604+ --dest=org.freedesktop.ScreenSaver \
605+ --type=method_call \
606+ /ScreenSaver \
607+ org.freedesktop.ScreenSaver.SetActive \
608+ boolean:true \
609+ 2> /dev/null
610+ result=$?
611+ ;;
612+
613+ lock)
614+ dbus-send --session \
615+ --dest=org.freedesktop.ScreenSaver \
616+ --type=method_call \
617+ /ScreenSaver \
618+ org.freedesktop.ScreenSaver.Lock \
619+ 2> /dev/null
620+ ;;
621+
622+ reset)
623+ if [ -f "$screensaver_file.cookie" ] ; then
624+ value=`cat "$screensaver_file.cookie"`
625+ dbus-send --session \
626+ --dest=org.freedesktop.ScreenSaver \
627+ --type=method_call \
628+ /ScreenSaver \
629+ org.freedesktop.ScreenSaver.UnInhibit \
630+ uint32:$value \
631+ 2> /dev/null
632+ rm -f "$screensaver_file.cookie"
633+ fi
634+ result=$?
635+ ;;
636+
637+ status)
638+ status=`dbus-send --session \
639+ --dest=org.freedesktop.ScreenSaver \
640+ --type=method_call \
641+ --print-reply \
642+ --reply-timeout=2000 \
643+ /ScreenSaver \
644+ org.freedesktop.ScreenSaver.GetActive \
645+ | grep boolean | cut -d ' ' -f 5`
646+ result=$?
647+ if [ x"$status" = "xtrue" ]; then
648+ echo "enabled"
649+ elif [ x"$status" = "xfalse" ]; then
650+ echo "disabled"
651+ else
652+ echo "ERROR: dbus org.freedesktop.ScreenSaver.GetActive returned '$status'" >&2
653+ return 1
654+ fi
655+ ;;
656+
657+ *)
658+ echo "ERROR: Unknown command '$1'" >&2
659+ return 1
660+ ;;
661+ esac
662+}
663+
664+screensaver_kde()
665+{
666+ case "$1" in
667+ suspend)
668+ dcop kdesktop KScreensaverIface enable false > /dev/null
669+ result=$?
670+ ;;
671+
672+ resume)
673+ dcop kdesktop KScreensaverIface configure > /dev/null
674+ result=$?
675+ ;;
676+
677+ activate)
678+ dcop kdesktop KScreensaverIface save > /dev/null
679+ result=$?
680+ ;;
681+
682+ lock)
683+ dcop kdesktop KScreensaverIface lock > /dev/null
684+ result=$?
685+ ;;
686+
687+ reset)
688+ # Turns the screensaver off right now
689+ dcop kdesktop KScreensaverIface quit > /dev/null
690+ result=$?
691+ ;;
692+
693+ status)
694+ status=`dcop kdesktop KScreensaverIface isEnabled`
695+ result=$?
696+ if [ x"$status" = "xtrue" ]; then
697+ echo "enabled"
698+ elif [ x"$status" = "xfalse" ]; then
699+ echo "disabled"
700+ else
701+ echo "ERROR: kdesktop KScreensaverIface isEnabled returned '$status'" >&2
702+ return 1
703+ fi
704+ ;;
705+
706+ *)
707+ echo "ERROR: Unknown command '$1'" >&2
708+ return 1
709+ ;;
710+ esac
711+}
712+
713+screensaver_xserver()
714+{
715+ case "$1" in
716+ suspend)
717+ xset s off > /dev/null
718+ result=$?
719+ ;;
720+
721+ resume)
722+ xset s default > /dev/null
723+ result=$?
724+ ;;
725+
726+ activate)
727+ xset s activate > /dev/null
728+ result=$?
729+ ;;
730+
731+ reset)
732+ xset s reset > /dev/null
733+ result=$?
734+ ;;
735+
736+ status)
737+ timeout=`xset q | sed '/^Screen Saver:/,/^[^ ]/ { s/.*timeout: *\([0-9]*\).*/\1/; t }; d'`
738+ result=$?
739+ if [ "$timeout" -gt 0 ]; then
740+ echo "enabled"
741+ elif [ "$timeout" -eq 0 ]; then
742+ echo "disabled"
743+ else
744+ echo "ERROR: xset q did not report the screensaver timeout" >&2
745+ return 1
746+ fi
747+ ;;
748+
749+ *)
750+ echo "ERROR: Unknown command '$1'" >&2
751+ return 1
752+ ;;
753+ esac
754+}
755+
756+screensaver_suspend_loop()
757+{
758+ lockfile
759+ test "${TMPDIR+set}" = set || TMPDIR=/tmp
760+ tmpfile=`mktemp $TMPDIR/tmp.XXXXXXXXXX`
761+ # Filter stale entries from the xdg-screensaver status file
762+ cat "$screensaver_file" 2> /dev/null | (
763+ IFS_save="$IFS"
764+ IFS=":"
765+ while read wid pid; do
766+ if ps -p "$pid" 2> /dev/null | grep xprop > /dev/null; then
767+ echo "$wid:$pid"
768+ fi
769+ done
770+ IFS="$IFS_save"
771+ ) > $tmpfile
772+ if [ -s "$tmpfile" ] ; then
773+ # Suspend pending, don't do a thing
774+ $MV "$tmpfile" "$screensaver_file"
775+ unlockfile
776+ return
777+ fi
778+ $MV "$tmpfile" "$screensaver_file"
779+ unlockfile
780+ (while [ -f "$screensaver_file" ]; do $*; sleep 50; done) > /dev/null 2> /dev/null &
781+}
782+
783+screensaver_gnome_screensaver()
784+{
785+# DBUS interface for gnome-screensaver
786+# http://people.gnome.org/~mccann/gnome-screensaver/docs/gnome-screensaver.html
787+ case "$1" in
788+ suspend)
789+ screensaver_suspend_loop \
790+ dbus-send --session \
791+ --dest=org.gnome.ScreenSaver \
792+ --type=method_call \
793+ /org/gnome/ScreenSaver \
794+ org.gnome.ScreenSaver.SimulateUserActivity \
795+ 2> /dev/null
796+ result=$?
797+ ;;
798+
799+ resume)
800+ # Automatic resume when $screensaver_file disappears
801+ result=0
802+ ;;
803+
804+ activate)
805+ dbus-send --session \
806+ --dest=org.gnome.ScreenSaver \
807+ --type=method_call \
808+ /org/gnome/ScreenSaver \
809+ org.gnome.ScreenSaver.SetActive \
810+ boolean:true \
811+ 2> /dev/null
812+ result=$?
813+ ;;
814+
815+ lock)
816+ gnome-screensaver-command --lock > /dev/null 2> /dev/null
817+ result=$?
818+ ;;
819+
820+ reset)
821+ # Turns the screensaver off right now
822+ dbus-send --session \
823+ --dest=org.gnome.ScreenSaver \
824+ --type=method_call \
825+ /org/gnome/ScreenSaver \
826+ org.gnome.ScreenSaver.SimulateUserActivity \
827+ 2> /dev/null
828+ result=$?
829+ ;;
830+
831+ status)
832+ status=`dbus-send --session \
833+ --dest=org.gnome.ScreenSaver \
834+ --type=method_call \
835+ --print-reply \
836+ --reply-timeout=2000 \
837+ /org/gnome/ScreenSaver \
838+ org.gnome.ScreenSaver.GetActive \
839+ | grep boolean | cut -d ' ' -f 5`
840+ result=$?
841+ if [ x"$status" = "xtrue" -o x"$status" = "xfalse" ]; then
842+ echo "enabled"
843+ elif [ x"$result" != "x0" ]; then
844+ echo "ERROR: dbus org.gnome.ScreenSaver.GetActive returned '$status'" >&2
845+ return 1
846+ else
847+ echo "disabled"
848+ fi
849+ ;;
850+
851+ *)
852+ echo "ERROR: Unknown command '$1" >&2
853+ return 1
854+ ;;
855+ esac
856+}
857+
858+screensaver_xscreensaver()
859+{
860+ case "$1" in
861+ suspend)
862+ screensaver_suspend_loop xscreensaver-command -deactivate
863+ result=0
864+ ;;
865+
866+ resume)
867+ # Automatic resume when $screensaver_file disappears
868+ result=0
869+ ;;
870+
871+ activate)
872+ xscreensaver-command -activate > /dev/null 2> /dev/null
873+ result=$?
874+ ;;
875+
876+ lock)
877+ xscreensaver-command -lock > /dev/null 2> /dev/null
878+ result=$?
879+ ;;
880+
881+ reset)
882+ # Turns the screensaver off right now
883+ xscreensaver-command -deactivate > /dev/null 2> /dev/null
884+ result=$?
885+ ;;
886+
887+ status)
888+ result=0
889+ if [ -f "$screensaver_file" ] ; then
890+ echo "disabled"
891+ else
892+ echo "enabled"
893+ fi
894+ ;;
895+
896+ *)
897+ echo "ERROR: Unknown command '$1" >&2
898+ return 1
899+ ;;
900+ esac
901+}
902+
903+[ x"$1" != x"" ] || exit_failure_syntax
904+
905+action=
906+window_id=
907+
908+case $1 in
909+ suspend)
910+ action="$1"
911+
912+ shift
913+
914+ if [ -z "$1" ] ; then
915+ exit_failure_syntax "WindowID argument missing"
916+ fi
917+
918+ window_id="$1"
919+ check_window_id
920+ ;;
921+
922+ resume)
923+ action="$1"
924+
925+ shift
926+
927+ if [ -z "$1" ] ; then
928+ exit_failure_syntax "WindowID argument missing"
929+ fi
930+
931+ window_id="$1"
932+ check_window_id
933+ ;;
934+
935+ activate)
936+ action="$1"
937+ ;;
938+
939+ lock)
940+ action="$1"
941+ ;;
942+
943+ reset)
944+ action="$1"
945+ ;;
946+
947+ status)
948+ action="$1"
949+ ;;
950+
951+ *)
952+ exit_failure_syntax "unknown command '$1'"
953+ ;;
954+esac
955+
956+detectDE
957+# Consider "xscreensaver" a separate DE
958+xscreensaver-command -version 2> /dev/null | grep XScreenSaver > /dev/null && DE="xscreensaver"
959+# Consider "gnome-screensaver" a separate DE
960+gnome-screensaver-command -q > /dev/null 2>&1 && DE="gnome_screensaver"
961+
962+if [ "$action" = "resume" ] ; then
963+ do_resume
964+ exit_success
965+fi
966+
967+perform_action "$action"
968+
969+if [ "$action" = "suspend" ] ; then
970+ # Start tracking $window_id and resume the screensaver once it disappears
971+ ( track_window ) 2> /dev/null > /dev/null &
972+fi
973+
974+if [ $result -eq 0 ]; then
975+ exit_success
976+else
977+ exit_failure_operation_failed
978+fi
979
980=== modified file 'debian/patches/series'
981--- debian/patches/series 2014-07-16 09:20:59 +0000
982+++ debian/patches/series 2015-01-17 16:43:41 +0000
983@@ -1,6 +1,5 @@
984 xdg-mime-follow-symlinks.diff
985 x-www-browser.diff
986-xserver-blanking.diff
987 xdg-email-envvar.diff
988 xdg-email-mutt-detect.diff
989 xdg-mime-generic-use-mimetype.diff
990@@ -12,3 +11,4 @@
991 lp779156-lubuntu.diff
992 xdg-screensaver-dbus.patch
993 xfce-blanking.diff
994+xdg-screensaver-restore-timeout.diff
995
996=== added file 'debian/patches/xdg-screensaver-restore-timeout.diff'
997--- debian/patches/xdg-screensaver-restore-timeout.diff 1970-01-01 00:00:00 +0000
998+++ debian/patches/xdg-screensaver-restore-timeout.diff 2015-01-17 16:43:41 +0000
999@@ -0,0 +1,50 @@
1000+Description: Restore previous X11 screensaver timeout (xdg-screensaver)
1001+Bug: https://bugs.freedesktop.org/show_bug.cgi?id=88210
1002+Ubuntu-Bug: https://bugs.launchpad.net/ubuntu/+source/xdg-utils/+bug/1363540
1003+Author: Thaddaeus Tintenfisch <thad.fisch@gmail.com>
1004+
1005+Index: xdg-utils/scripts/xdg-screensaver
1006+===================================================================
1007+--- xdg-utils.orig/scripts/xdg-screensaver 2015-01-17 15:51:17.548973598 +0100
1008++++ xdg-utils/scripts/xdg-screensaver 2015-01-17 15:52:33.633020130 +0100
1009+@@ -690,16 +690,29 @@
1010+ esac
1011+ }
1012+
1013++xset_screensaver_timeout()
1014++{
1015++ xset q | sed '/^Screen Saver:/,/^[^ ]/ { s/.*timeout: *\([0-9]*\).*/\1/; t }; d'
1016++}
1017++
1018+ screensaver_xserver()
1019+ {
1020+ case "$1" in
1021+ suspend)
1022+- xset s off > /dev/null
1023++ timeout=`xset_screensaver_timeout`
1024++ if [ "$timeout" -gt 0 ]; then
1025++ echo "$timeout" > "$screensaver_file.xset"
1026++ xset s off > /dev/null
1027++ fi
1028+ result=$?
1029+ ;;
1030+
1031+ resume)
1032+- xset s default > /dev/null
1033++ if [ -f "$screensaver_file.xset" ] ; then
1034++ value=`cat "$screensaver_file.xset"`
1035++ xset s $value > /dev/null
1036++ rm -f "$screensaver_file.xset"
1037++ fi
1038+ result=$?
1039+ ;;
1040+
1041+@@ -714,7 +727,7 @@
1042+ ;;
1043+
1044+ status)
1045+- timeout=`xset q | sed '/^Screen Saver:/,/^[^ ]/ { s/.*timeout: *\([0-9]*\).*/\1/; t }; d'`
1046++ timeout=`xset_screensaver_timeout`
1047+ result=$?
1048+ if [ "$timeout" -gt 0 ]; then
1049+ echo "enabled"
1050
1051=== removed file 'debian/patches/xserver-blanking.diff'
1052--- debian/patches/xserver-blanking.diff 2011-02-20 18:34:53 +0000
1053+++ debian/patches/xserver-blanking.diff 1970-01-01 00:00:00 +0000
1054@@ -1,68 +0,0 @@
1055-Description: Support X server blanking in xdg-screensaver.
1056-Bug: https://bugs.freedesktop.org/show_bug.cgi?id=30561
1057-Bug-Debian: http://bugs.debian.org/511248
1058-Author: Ben Hutchings <ben@decadent.org.uk>
1059-
1060---- a/scripts/xdg-screensaver
1061-+++ b/scripts/xdg-screensaver
1062-@@ -435,6 +435,10 @@ perform_action()
1063- '')
1064- screensaver_xserver "$1"
1065- ;;
1066-+
1067-+ '')
1068-+ screensaver_xserver "$1"
1069-+ ;;
1070- esac
1071-
1072- if [ "$1" = "suspend" ] ; then
1073-@@ -682,6 +686,49 @@ screensaver_kde()
1074- return 1
1075- fi
1076- ;;
1077-+
1078-+ *)
1079-+ echo "ERROR: Unknown command '$1'" >&2
1080-+ return 1
1081-+ ;;
1082-+ esac
1083-+}
1084-+
1085-+screensaver_xserver()
1086-+{
1087-+ case "$1" in
1088-+ suspend)
1089-+ xset s off > /dev/null
1090-+ result=$?
1091-+ ;;
1092-+
1093-+ resume)
1094-+ xset s default > /dev/null
1095-+ result=$?
1096-+ ;;
1097-+
1098-+ activate)
1099-+ xset s activate > /dev/null
1100-+ result=$?
1101-+ ;;
1102-+
1103-+ reset)
1104-+ xset s reset > /dev/null
1105-+ result=$?
1106-+ ;;
1107-+
1108-+ status)
1109-+ timeout=`xset q | sed '/^Screen Saver:/,/^[^ ]/ { s/.*timeout: *\([0-9]*\).*/\1/; t }; d'`
1110-+ result=$?
1111-+ if [ "$timeout" -gt 0 ]; then
1112-+ echo "enabled"
1113-+ elif [ "$timeout" -eq 0 ]; then
1114-+ echo "disabled"
1115-+ else
1116-+ echo "ERROR: xset q did not report the screensaver timeout" >&2
1117-+ return 1
1118-+ fi
1119-+ ;;
1120-
1121- *)
1122- echo "ERROR: Unknown command '$1'" >&2
1123
1124=== modified file 'scripts/xdg-screensaver'
1125--- scripts/xdg-screensaver 2014-07-16 09:20:59 +0000
1126+++ scripts/xdg-screensaver 2015-01-17 16:43:41 +0000
1127@@ -694,16 +694,29 @@
1128 esac
1129 }
1130
1131+xset_screensaver_timeout()
1132+{
1133+ xset q | sed '/^Screen Saver:/,/^[^ ]/ { s/.*timeout: *\([0-9]*\).*/\1/; t }; d'
1134+}
1135+
1136 screensaver_xserver()
1137 {
1138 case "$1" in
1139 suspend)
1140- xset s off > /dev/null
1141+ timeout=`xset_screensaver_timeout`
1142+ if [ "$timeout" -gt 0 ]; then
1143+ echo "$timeout" > "$screensaver_file.xset"
1144+ xset s off > /dev/null
1145+ fi
1146 result=$?
1147 ;;
1148
1149 resume)
1150- xset s default > /dev/null
1151+ if [ -f "$screensaver_file.xset" ] ; then
1152+ value=`cat "$screensaver_file.xset"`
1153+ xset s $value > /dev/null
1154+ rm -f "$screensaver_file.xset"
1155+ fi
1156 result=$?
1157 ;;
1158
1159@@ -718,7 +731,7 @@
1160 ;;
1161
1162 status)
1163- timeout=`xset q | sed '/^Screen Saver:/,/^[^ ]/ { s/.*timeout: *\([0-9]*\).*/\1/; t }; d'`
1164+ timeout=`xset_screensaver_timeout`
1165 result=$?
1166 if [ "$timeout" -gt 0 ]; then
1167 echo "enabled"
1168@@ -737,49 +750,6 @@
1169 esac
1170 }
1171
1172-screensaver_xserver()
1173-{
1174- case "$1" in
1175- suspend)
1176- xset s off > /dev/null
1177- result=$?
1178- ;;
1179-
1180- resume)
1181- xset s default > /dev/null
1182- result=$?
1183- ;;
1184-
1185- activate)
1186- xset s activate > /dev/null
1187- result=$?
1188- ;;
1189-
1190- reset)
1191- xset s reset > /dev/null
1192- result=$?
1193- ;;
1194-
1195- status)
1196- timeout=`xset q | sed '/^Screen Saver:/,/^[^ ]/ { s/.*timeout: *\([0-9]*\).*/\1/; t }; d'`
1197- result=$?
1198- if [ "$timeout" -gt 0 ]; then
1199- echo "enabled"
1200- elif [ "$timeout" -eq 0 ]; then
1201- echo "disabled"
1202- else
1203- echo "ERROR: xset q did not report the screensaver timeout" >&2
1204- return 1
1205- fi
1206- ;;
1207-
1208- *)
1209- echo "ERROR: Unknown command '$1'" >&2
1210- return 1
1211- ;;
1212- esac
1213-}
1214-
1215 screensaver_suspend_loop()
1216 {
1217 lockfile

Subscribers

People subscribed via source and target branches

to all changes: