Commit 3d6d1a33 authored by Jarno Suni's avatar Jarno Suni
Browse files

xflock4: Add debug function

The debug function is controlled by xfce4-session property
/general/LockDebugFile (string) in Xfconf. If it exist and is non-null,
more output will generated in standard error which will be redirected
to the given file. Also standard output will be redirected to that
file. Besides, shell trace output mode will be switched on.
parent a3084c10
......@@ -22,6 +22,17 @@
set -eu
unset -v IFS
# find a free file descriptor
FD=3; while { >&$FD; } 2>/dev/null; do FD=$((FD+1)); done
# get string
DEBUG=$(xfconf-query -c xfce4-session -p /general/LockDebugFile || :)
[ -n "$DEBUG" ] && {
exec >"$DEBUG" 2>&1
eval "exec $FD>&1"
set -x
} || eval "exec $FD>/dev/null"
# Sleep time given in decimal number $1. The unit is second.
# Try to do that even in a system in which sleep command does not
# support non-integer time.
......@@ -31,7 +42,7 @@ real_sleep() {
|| sleep "$(( ${1%%.*} + 1 ))" # in case perl is not installed
# and non-integer sleep is supported, determine time by ceiling
# function to get at least given amount of delay.
} 2>/dev/null
} 2>&$FD
# Turn off display after given time in seconds.
initial_dpms() {
......@@ -148,11 +159,11 @@ for lock_cmd in \
do
# To redirect stdin to /dev/null is needed at least for xscreensaver
# to not have 1 s delay when invoked on terminal.
${lock_cmd}-command --lock </dev/null 2>/dev/null && exit
${lock_cmd}-command --lock </dev/null 2>&$FD && exit
done
# 'gnome-screensaver-command --lock' always returns 0 even if it does
# not lock. (Version 3.6.1 at least.)
# Thus running with '--query' first is needed.
[ -n "$(gnome-screensaver-command --query 2>/dev/null)" ] \
&& gnome-screensaver-command --lock </dev/null 2>/dev/null
[ -n "$(gnome-screensaver-command --query 2>&$FD)" ] \
&& gnome-screensaver-command --lock </dev/null 2>&$FD
......@@ -9,6 +9,7 @@
<property name="LockModeDPMS" type="string" value="off"/>
<property name="LockInitialDelayDPMS" type="uint" value="1"/>
<property name="LockDelayDPMS" type="uint" value="15"/>
<property name="LockDebugFile" type="string" value=""/>
</property>
<property name="sessions" type="empty">
<property name="Failsafe" type="empty">
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment