xrandr: don't poll hardware when it's not needed

This commit is contained in:
Vincent Bernat 2020-01-29 11:16:05 +01:00
parent 95dd95e4ce
commit 08fa9a63d0
2 changed files with 2 additions and 2 deletions

View file

@ -3,7 +3,7 @@
DISPLAY=${DISPLAY%.0}
# For information
xrandr \
xrandr --current \
| sed -n 's/^\([^ ]\)* connected.* \([0-9]*\)x.* \([0-9]*\)mm x .*/\1 \2 \3/p' \
| while read output pixels mm; do
dpi=$(($pixels * 25.4 / $mm))

View file

@ -24,7 +24,7 @@ case "$1" in
trap "systemctl --user kill -s CONT redshift@$(systemd-escape -- "$DISPLAY").service" EXIT
trap 'echo notify: user activity; kill %% 2> /dev/null; exit 0' HUP # user activity
trap 'echo notify: locker started; kill %% 2> /dev/null; exit 0' TERM # locker started
outputs=($(xrandr -q | sed -n 's/\([^ ]*\) connected .*/\1/p'))
outputs=($(xrandr --current | sed -n 's/\([^ ]*\) connected .*/\1/p'))
for out in ${outputs[@]}; do
xrandr --output $out --brightness 0.2
done