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.
This commit is contained in:
Vincent Bernat 2020-01-24 19:55:19 +01:00
parent feb4ae0793
commit 340f063b4e

View file

@ -20,22 +20,23 @@ case "$1" in
;; ;;
dim|notify) dim|notify)
echo "notify: start" 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 \ current=$(xrandr --verbose | sed -n \
-e 's/\([^ ]*\) connected .*/--output \1/p' \ -e 's/\([^ ]*\) connected .*/--output \1/p' \
-e 's/\t*Gamma: *\([^ ]\)/--gamma \1/p' \ -e 's/\t*Gamma: *\([^ ]\)/--gamma \1/p' \
-e 's/\t*Brightness: *\([^ ]\)/--brightness \1/p' | \ -e 's/\t*Brightness: *\([^ ]\)/--brightness \1/p' | \
tr '\n' ' ') 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 'kill %% 2> /dev/null; exit 0' HUP # user activity
trap 'sleep 0.2s; kill %% 2> /dev/null; exit 0' TERM # locker started 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 i in $(seq 0.7 -0.01 0.1); do
for out in ${outputs[@]}; do xrandr $(echo $current | sed "s/\(--brightness\) [^ ]*/\1 $i/g")
xrandr --output $out --brightness $i || \ sleep 0.05
outputs=("${outputs[@]/$out}")
done
sleep 0.1
done done
echo "notify: end" echo "notify: end"
sleep infinity & sleep infinity &