wok-current annotate xorg-xset/stuff/xset-screensaver.sh @ rev 24367

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