mirror of
https://github.com/vincentbernat/i3wm-configuration.git
synced 2025-07-14 20:24:22 +02:00
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.
57 lines
2 KiB
Bash
Executable file
57 lines
2 KiB
Bash
Executable file
#!/bin/bash
|
|
|
|
me="$(readlink -f "$0")"
|
|
timeout=300
|
|
notify=10
|
|
|
|
configure() {
|
|
xset s $((timeout - notify)) $notify
|
|
xset dpms $((timeout * 3)) $((timeout * 4)) $((timeout * 5))
|
|
}
|
|
unconfigure() {
|
|
xset s 0
|
|
xset dpms 0 0 0
|
|
}
|
|
|
|
case "$1" in
|
|
start)
|
|
configure
|
|
exec xss-lock -s ${XDG_SESSION_ID} -n "$me notify" -l $me lock
|
|
;;
|
|
dim|notify)
|
|
echo "notify: start"
|
|
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 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
|
|
for i in $(seq 0.7 -0.01 0.1); do
|
|
xrandr $(echo $current | sed "s/\(--brightness\) [^ ]*/\1 $i/g")
|
|
sleep 0.05
|
|
done
|
|
echo "notify: end"
|
|
sleep infinity &
|
|
wait
|
|
;;
|
|
lock)
|
|
# Something may have mendled with screensaver settings
|
|
configure
|
|
# First, stop any music player
|
|
xdotool key XF86AudioStop
|
|
# Then, lock screen
|
|
echo "lock: lock screen"
|
|
systemctl --user stop compton@$(systemd-escape -- "$DISPLAY").service
|
|
i3lock -n -e -i $HOME/.cache/awesome/current-wallpaper.png -t -f
|
|
systemctl --user start compton@$(systemd-escape -- "$DISPLAY").service
|
|
echo "lock: unlock screen"
|
|
;;
|
|
esac
|