mirror of
https://github.com/vincentbernat/i3wm-configuration.git
synced 2025-07-08 01:04:21 +02:00
51 lines
1.4 KiB
Bash
Executable file
51 lines
1.4 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"
|
|
pkill -STOP redshift
|
|
trap 'pkill -CONT redshift' EXIT
|
|
trap 'kill %% 2> /dev/null; exit 0' HUP
|
|
trap 'sleep 1s; kill %% 2> /dev/null; exit 0' TERM
|
|
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
|
|
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
|