wok-6.x view xorg-xset/stuff/xset-screensaver.sh @ rev 21975

updated st (0.5 -> 0.8.2)
author Hans-G?nter Theisgen
date Fri Oct 11 14:31:25 2019 +0100 (2019-10-11)
parents 11bd286c39d2
children
line source
1 #!/bin/sh
2 #
3 [ -z $(which yad) ] && exec yad && exit 0
5 case $(id -u) in
6 0) path=/etc/xdg ;;
7 *) path=${XDG_CONFIG_HOME:-$HOME/.config}
8 [ -f "$path/autostart" ] && mv $path/autostart $path/autostart.bak
9 [ -d "$path/autostart" ] || mkdir -p $path/autostart ;;
10 esac
12 AutostartFile="$path/autostart/xset-screensaver.desktop"
13 launcher='/usr/share/applications/xorg-xset.desktop' # Must be same as package name
15 exec_d()
16 {
17 cmd=$(cat $AutostartFile | grep Exec | sed 's/Exec=//') ; $cmd
18 }
20 [ -f $AutostartFile ] && exec_d
22 case $LC_ALL in
23 C|POSIX|en*) lang='=' ;;
24 *) lang='\['${LC_ALL%_*}
25 grep -q '\['${LC_ALL%_*} $launcher || lang='=' ;;
26 esac
30 val=$(yad --title="$(cat $launcher | grep Name$lang | cut -d'=' -f2)" \
31 --scale --max-value=18000 --mark="1h.":3600 --buttons-layout=spread \
32 --mark="$(cat $launcher | grep Comment$lang | cut -d'=' -f2 | cut -d',' -f1)":0 \
33 --mark="120min.(2h.)":7200 --mark="180min.(3h.)":10800 \
34 --mark="240min.(4h.)":14400 --mark="300min.(5h.)":18000 \
35 --page=1800 --step=60 --geometry=630x42+10+100 \
36 --value=$(xset q | grep timeout | cut -d' ' -f5) \
37 --window-icon="preferences-desktop-screensaver" )
39 [ -z $val ] || cat > $AutostartFile <<EOT
40 [Desktop Entry]
41 Type=Application
42 Name=xset screensaver timeout
43 Exec=xset dpms $val $val $val s $val $val
44 EOT
46 exec_d
48 # Notes: 'xset s' max val is 32767, 'xset dpms' limit is unknown
49 exit 0