xss-lock: restore gamma/brightness on exit

redshift may take some time to restore it.
This commit is contained in:
Vincent Bernat 2020-01-24 19:18:18 +01:00
parent 864fd73bf9
commit feb4ae0793

View file

@ -21,9 +21,14 @@ case "$1" in
dim|notify) dim|notify)
echo "notify: start" echo "notify: start"
pkill -STOP redshift pkill -STOP redshift
trap 'pkill -CONT redshift' EXIT current=$(xrandr --verbose | sed -n \
trap 'kill %% 2> /dev/null; exit 0' HUP -e 's/\([^ ]*\) connected .*/--output \1/p' \
trap 'sleep 1s; kill %% 2> /dev/null; exit 0' TERM -e 's/\t*Gamma: *\([^ ]\)/--gamma \1/p' \
-e 's/\t*Brightness: *\([^ ]\)/--brightness \1/p' | \
tr '\n' ' ')
trap "echo resume redshift; xrandr $current; pkill -CONT redshift" EXIT
trap 'kill %% 2> /dev/null; exit 0' HUP # user activity
trap 'sleep 0.2s; kill %% 2> /dev/null; exit 0' TERM # locker started
outputs=($(xrandr -q | sed -n 's/\([^ ]*\) connected .*/\1/p')) outputs=($(xrandr -q | sed -n 's/\([^ ]*\) connected .*/\1/p'))
for i in $(seq 0.7 -0.01 0.1); do for i in $(seq 0.7 -0.01 0.1); do
for out in ${outputs[@]}; do for out in ${outputs[@]}; do