From 340f063b4ea84a68caec22f6fa39823af9237b85 Mon Sep 17 00:00:00 2001 From: Vincent Bernat Date: Fri, 24 Jan 2020 19:55:19 +0100 Subject: [PATCH] xss-lock: tentative to keep current gamma This doesn't seem to work. It seems xrandr 1.5.0 doesn't set gamma values correctly, but even xrandr 1.5.1 seems to have an issue setting the appropriate gamma value from an existing value. --- bin/xss-lock | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/bin/xss-lock b/bin/xss-lock index 2e73014..4d67239 100755 --- a/bin/xss-lock +++ b/bin/xss-lock @@ -20,22 +20,23 @@ case "$1" in ;; dim|notify) echo "notify: start" - pkill -STOP redshift + redshift=$(systemctl --user show \ + --property MainPID \ + --value redshift@$(systemd-escape -- "$DISPLAY").service) + [ x$redshift = x ] || kill -STOP $redshift current=$(xrandr --verbose | sed -n \ -e 's/\([^ ]*\) connected .*/--output \1/p' \ -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 "echo notify: restore brightness; + xrandr $current; + [ x$redshift = x ] || kill -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')) for i in $(seq 0.7 -0.01 0.1); do - for out in ${outputs[@]}; do - xrandr --output $out --brightness $i || \ - outputs=("${outputs[@]/$out}") - done - sleep 0.1 + xrandr $(echo $current | sed "s/\(--brightness\) [^ ]*/\1 $i/g") + sleep 0.05 done echo "notify: end" sleep infinity &