Merge lp:~ochosi/xdg-utils/support_xfce into lp:ubuntu/utopic/xdg-utils

Proposed by Simon Steinbeiß on 2014-06-23
Status: Merged
Merged at revision: 23
Proposed branch: lp:~ochosi/xdg-utils/support_xfce
Merge into: lp:ubuntu/utopic/xdg-utils
Diff against target: 1081 lines (+1034/-1)
6 files modified
.pc/applied-patches (+1/-0)
.pc/xfce-blanking.diff/scripts/xdg-screensaver (+1005/-0)
debian/changelog (+7/-0)
debian/patches/series (+1/-0)
debian/patches/xfce-blanking.diff (+19/-0)
scripts/xdg-screensaver (+1/-1)
To merge this branch: bzr merge lp:~ochosi/xdg-utils/support_xfce
Reviewer Review Type Date Requested Status
Didier Roche Approve on 2014-07-16
Sebastien Bacher 2014-06-23 Needs Information on 2014-07-07
Review via email: mp+224076@code.launchpad.net

This proposal supersedes a proposal from 2014-06-16.

Description of the change

This is a very simple patch that provides a fallback for the Xfce DE. Until 14.04, we used xscreensaver, so there was no special case needed for Xfce. However, now that we're using light-locker, xdg-screensaver should handle the X11 screensaver extension's settings (if XScreenSaver isn't installed or in use).

This simple patch does exactly that. It checks for the "xfce" DE *after* checking for XScreenSaver and then let's xdg-screensaver handle things correctly.

This branch fixes https://bugs.launchpad.net/ubuntu/+source/xdg-utils/+bug/1309744

To post a comment you must log in.
Simon Steinbeiß (ochosi) wrote : Posted in a previous version of this proposal

Here goes the upstream bugreport: https://bugs.freedesktop.org/show_bug.cgi?id=80089

Sebastien Bacher (seb128) wrote : Posted in a previous version of this proposal

Thanks, could you change the merge target to be lp:ubuntu/xdg-utils? The change seems fine to me, but I see that there is some alternative approch discussion on the upstream bug report, so I'm going to wait a few days to see if things come to an agreement there and use the upstream solution if they get one

Sebastien Bacher (seb128) wrote :

Looking to that again, your upstream merge request patches the .in, should we do the same here in case those files got regenerated? You also mentioned that the change would be a candidate for a SRU, could update the bug report with the rational/test case/regression potential informations?

review: Needs Information
Simon Steinbeiß (ochosi) wrote :

> Looking to that again, your upstream merge request patches the .in, should we
> do the same here in case those files got regenerated?

Yeah, that would make sense I guess.

> You also mentioned that the change would be a candidate for a SRU, could update the bug report with
> the rational/test case/regression potential informations?

I thought I need to report a separate bug for the SRU anyhow with all that information, but only after it's in Utopic?
I can also do it now, I guess I was just confused there about the exact procedure.

Didier Roche (didrocks) wrote :

for reference:
didrocks | ochosi: seems that you are doing an inline patch
didrocks | would be better to add it as a patch
didrocks | also, I think you can break other use case with replacing '' by 'xfce'
  ochosi | no
didrocks | shouldn't you just append (before the '') the 'xfce' case?
  ochosi | the thing is, that there is a second ''
  ochosi | i submitted another bug report about that
  ochosi | ubuntu is carrying a useless patch, which duplicates code
didrocks | ah indeed
  ochosi | so i thought i'd use that duplication to my advantage for now
didrocks | so yeah, the replacement is fine
  ochosi | simply to produce the most minimal patch
  ochosi | to get SRU'd ;)
didrocks | however, this should be carried as a patch, not an inline change?
  ochosi | sure, i'm fine with that
didrocks | ochosi: ok, just do that change and I'll +1 for utopic
  ochosi | although after it's SRU'd I think it should be done properly
didrocks | ochosi: yeah, try to get it into debian/upstream to not have that as a patch :)
  ochosi | i've gotten in touch with upstream, but after the initial reply i haven't heard back...
  ochosi | ofc :)
  ochosi | i know it's a bit silly
didrocks | but let's do it as a patch first to unblock your SRU
  ochosi | yup, thanks!
didrocks | yw, just ping me back :)
didrocks | (also provides a changelog with the bug ref and so on)
  ochosi | ok, i haven't ever done a debian patch, but i'll give it a shot
       * | ochosi isn't a coder anyways...
didrocks | ochosi: poke me if you need any help, look for "quilt" ;)
didrocks | ochosi: https://wiki.debian.org/UsingQuilt
       * | ochosi only understands "scotland"
didrocks | and http://packaging.ubuntu.com/html/patches-to-packages.html
didrocks | heh ;)

review: Needs Fixing
lp:~ochosi/xdg-utils/support_xfce updated on 2014-07-16
22. By Simon Steinbeiß on 2014-07-16

Add fallback-mode for Xfce (only gets used if xscreensaver isn't installed/in use)

23. By Simon Steinbeiß on 2014-07-16

Add patch tags

Didier Roche (didrocks) wrote :

approving with latest changes

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 2011-10-03 16:06:10 +0000
3+++ .pc/applied-patches 2014-07-16 09:36:41 +0000
4@@ -11,3 +11,4 @@
5 gnome-3.0.diff
6 lp779156-lubuntu.diff
7 xdg-screensaver-dbus.patch
8+xfce-blanking.diff
9
10=== added directory '.pc/xfce-blanking.diff'
11=== added file '.pc/xfce-blanking.diff/.timestamp'
12=== added directory '.pc/xfce-blanking.diff/scripts'
13=== added file '.pc/xfce-blanking.diff/scripts/xdg-screensaver'
14--- .pc/xfce-blanking.diff/scripts/xdg-screensaver 1970-01-01 00:00:00 +0000
15+++ .pc/xfce-blanking.diff/scripts/xdg-screensaver 2014-07-16 09:36:41 +0000
16@@ -0,0 +1,1005 @@
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+ '')
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_xserver()
757+{
758+ case "$1" in
759+ suspend)
760+ xset s off > /dev/null
761+ result=$?
762+ ;;
763+
764+ resume)
765+ xset s default > /dev/null
766+ result=$?
767+ ;;
768+
769+ activate)
770+ xset s activate > /dev/null
771+ result=$?
772+ ;;
773+
774+ reset)
775+ xset s reset > /dev/null
776+ result=$?
777+ ;;
778+
779+ status)
780+ timeout=`xset q | sed '/^Screen Saver:/,/^[^ ]/ { s/.*timeout: *\([0-9]*\).*/\1/; t }; d'`
781+ result=$?
782+ if [ "$timeout" -gt 0 ]; then
783+ echo "enabled"
784+ elif [ "$timeout" -eq 0 ]; then
785+ echo "disabled"
786+ else
787+ echo "ERROR: xset q did not report the screensaver timeout" >&2
788+ return 1
789+ fi
790+ ;;
791+
792+ *)
793+ echo "ERROR: Unknown command '$1'" >&2
794+ return 1
795+ ;;
796+ esac
797+}
798+
799+screensaver_suspend_loop()
800+{
801+ lockfile
802+ test "${TMPDIR+set}" = set || TMPDIR=/tmp
803+ tmpfile=`mktemp $TMPDIR/tmp.XXXXXXXXXX`
804+ # Filter stale entries from the xdg-screensaver status file
805+ cat "$screensaver_file" 2> /dev/null | (
806+ IFS_save="$IFS"
807+ IFS=":"
808+ while read wid pid; do
809+ if ps -p "$pid" 2> /dev/null | grep xprop > /dev/null; then
810+ echo "$wid:$pid"
811+ fi
812+ done
813+ IFS="$IFS_save"
814+ ) > $tmpfile
815+ if [ -s "$tmpfile" ] ; then
816+ # Suspend pending, don't do a thing
817+ $MV "$tmpfile" "$screensaver_file"
818+ unlockfile
819+ return
820+ fi
821+ $MV "$tmpfile" "$screensaver_file"
822+ unlockfile
823+ (while [ -f "$screensaver_file" ]; do $*; sleep 50; done) > /dev/null 2> /dev/null &
824+}
825+
826+screensaver_gnome_screensaver()
827+{
828+# DBUS interface for gnome-screensaver
829+# http://people.gnome.org/~mccann/gnome-screensaver/docs/gnome-screensaver.html
830+ case "$1" in
831+ suspend)
832+ screensaver_suspend_loop \
833+ dbus-send --session \
834+ --dest=org.gnome.ScreenSaver \
835+ --type=method_call \
836+ /org/gnome/ScreenSaver \
837+ org.gnome.ScreenSaver.SimulateUserActivity \
838+ 2> /dev/null
839+ result=$?
840+ ;;
841+
842+ resume)
843+ # Automatic resume when $screensaver_file disappears
844+ result=0
845+ ;;
846+
847+ activate)
848+ dbus-send --session \
849+ --dest=org.gnome.ScreenSaver \
850+ --type=method_call \
851+ /org/gnome/ScreenSaver \
852+ org.gnome.ScreenSaver.SetActive \
853+ boolean:true \
854+ 2> /dev/null
855+ result=$?
856+ ;;
857+
858+ lock)
859+ gnome-screensaver-command --lock > /dev/null 2> /dev/null
860+ result=$?
861+ ;;
862+
863+ reset)
864+ # Turns the screensaver off right now
865+ dbus-send --session \
866+ --dest=org.gnome.ScreenSaver \
867+ --type=method_call \
868+ /org/gnome/ScreenSaver \
869+ org.gnome.ScreenSaver.SimulateUserActivity \
870+ 2> /dev/null
871+ result=$?
872+ ;;
873+
874+ status)
875+ status=`dbus-send --session \
876+ --dest=org.gnome.ScreenSaver \
877+ --type=method_call \
878+ --print-reply \
879+ --reply-timeout=2000 \
880+ /org/gnome/ScreenSaver \
881+ org.gnome.ScreenSaver.GetActive \
882+ | grep boolean | cut -d ' ' -f 5`
883+ result=$?
884+ if [ x"$status" = "xtrue" -o x"$status" = "xfalse" ]; then
885+ echo "enabled"
886+ elif [ x"$result" != "x0" ]; then
887+ echo "ERROR: dbus org.gnome.ScreenSaver.GetActive returned '$status'" >&2
888+ return 1
889+ else
890+ echo "disabled"
891+ fi
892+ ;;
893+
894+ *)
895+ echo "ERROR: Unknown command '$1" >&2
896+ return 1
897+ ;;
898+ esac
899+}
900+
901+screensaver_xscreensaver()
902+{
903+ case "$1" in
904+ suspend)
905+ screensaver_suspend_loop xscreensaver-command -deactivate
906+ result=0
907+ ;;
908+
909+ resume)
910+ # Automatic resume when $screensaver_file disappears
911+ result=0
912+ ;;
913+
914+ activate)
915+ xscreensaver-command -activate > /dev/null 2> /dev/null
916+ result=$?
917+ ;;
918+
919+ lock)
920+ xscreensaver-command -lock > /dev/null 2> /dev/null
921+ result=$?
922+ ;;
923+
924+ reset)
925+ # Turns the screensaver off right now
926+ xscreensaver-command -deactivate > /dev/null 2> /dev/null
927+ result=$?
928+ ;;
929+
930+ status)
931+ result=0
932+ if [ -f "$screensaver_file" ] ; then
933+ echo "disabled"
934+ else
935+ echo "enabled"
936+ fi
937+ ;;
938+
939+ *)
940+ echo "ERROR: Unknown command '$1" >&2
941+ return 1
942+ ;;
943+ esac
944+}
945+
946+[ x"$1" != x"" ] || exit_failure_syntax
947+
948+action=
949+window_id=
950+
951+case $1 in
952+ suspend)
953+ action="$1"
954+
955+ shift
956+
957+ if [ -z "$1" ] ; then
958+ exit_failure_syntax "WindowID argument missing"
959+ fi
960+
961+ window_id="$1"
962+ check_window_id
963+ ;;
964+
965+ resume)
966+ action="$1"
967+
968+ shift
969+
970+ if [ -z "$1" ] ; then
971+ exit_failure_syntax "WindowID argument missing"
972+ fi
973+
974+ window_id="$1"
975+ check_window_id
976+ ;;
977+
978+ activate)
979+ action="$1"
980+ ;;
981+
982+ lock)
983+ action="$1"
984+ ;;
985+
986+ reset)
987+ action="$1"
988+ ;;
989+
990+ status)
991+ action="$1"
992+ ;;
993+
994+ *)
995+ exit_failure_syntax "unknown command '$1'"
996+ ;;
997+esac
998+
999+detectDE
1000+# Consider "xscreensaver" a separate DE
1001+xscreensaver-command -version 2> /dev/null | grep XScreenSaver > /dev/null && DE="xscreensaver"
1002+# Consider "gnome-screensaver" a separate DE
1003+gnome-screensaver-command -q > /dev/null 2>&1 && DE="gnome_screensaver"
1004+
1005+if [ "$action" = "resume" ] ; then
1006+ do_resume
1007+ exit_success
1008+fi
1009+
1010+perform_action "$action"
1011+
1012+if [ "$action" = "suspend" ] ; then
1013+ # Start tracking $window_id and resume the screensaver once it disappears
1014+ ( track_window ) 2> /dev/null > /dev/null &
1015+fi
1016+
1017+if [ $result -eq 0 ]; then
1018+ exit_success
1019+else
1020+ exit_failure_operation_failed
1021+fi
1022
1023=== modified file 'debian/changelog'
1024--- debian/changelog 2013-03-20 19:37:26 +0000
1025+++ debian/changelog 2014-07-16 09:36:41 +0000
1026@@ -1,3 +1,10 @@
1027+xdg-utils (1.1.0~rc1-2ubuntu8) UNRELEASED; urgency=medium
1028+
1029+ * Add patch xfce-blanking.diff to prevent screenblanking in Xfce when
1030+ XScreensaver isn't installed/used
1031+
1032+ -- Simon Steinbeiss <ochosi@shimmerproject.org> Wed, 16 Jul 2014 11:19:43 +0200
1033+
1034 xdg-utils (1.1.0~rc1-2ubuntu7) raring; urgency=low
1035
1036 * Mark as Multi-Arch: foreign (Closes: #688681, LP: #1123710)
1037
1038=== modified file 'debian/patches/series'
1039--- debian/patches/series 2011-10-03 16:06:10 +0000
1040+++ debian/patches/series 2014-07-16 09:36:41 +0000
1041@@ -11,3 +11,4 @@
1042 gnome-3.0.diff
1043 lp779156-lubuntu.diff
1044 xdg-screensaver-dbus.patch
1045+xfce-blanking.diff
1046
1047=== added file 'debian/patches/xfce-blanking.diff'
1048--- debian/patches/xfce-blanking.diff 1970-01-01 00:00:00 +0000
1049+++ debian/patches/xfce-blanking.diff 2014-07-16 09:36:41 +0000
1050@@ -0,0 +1,19 @@
1051+Description: xdg-screensaver should control X11's blanking in Xfce (BR80089)
1052+Bug: https://bugs.freedesktop.org/show_bug.cgi?id=80089
1053+Ubuntu-Bug: https://bugs.launchpad.net/ubuntu/+source/xdg-utils/+bug/1309744
1054+Forwarded: https://bugs.freedesktop.org/attachment.cgi?id=101155
1055+Author: Simon Steinbeiss
1056+
1057+Index: xdg-utils/scripts/xdg-screensaver
1058+===================================================================
1059+--- xdg-utils.orig/scripts/xdg-screensaver 2014-07-16 11:17:08.583020000 +0200
1060++++ xdg-utils/scripts/xdg-screensaver 2014-07-16 11:17:33.653383192 +0200
1061+@@ -432,7 +432,7 @@
1062+ screensaver_xscreensaver "$1"
1063+ ;;
1064+
1065+- '')
1066++ xfce)
1067+ screensaver_xserver "$1"
1068+ ;;
1069+
1070
1071=== modified file 'scripts/xdg-screensaver'
1072--- scripts/xdg-screensaver 2011-10-03 16:06:10 +0000
1073+++ scripts/xdg-screensaver 2014-07-16 09:36:41 +0000
1074@@ -432,7 +432,7 @@
1075 screensaver_xscreensaver "$1"
1076 ;;
1077
1078- '')
1079+ xfce)
1080 screensaver_xserver "$1"
1081 ;;
1082

Subscribers

People subscribed via source and target branches