mirror of
https://github.com/vincentbernat/i3wm-configuration.git
synced 2025-06-27 03:58:51 +02:00
This is derived from my Awesome configuration. Still a lot to do from a WM perspective. The organization is a bit different and I am giving it up on the per-display systemd units as it does not really work due to the fact we only have one user DBus and one environment.
46 lines
1.4 KiB
Bash
Executable file
46 lines
1.4 KiB
Bash
Executable file
#!/bin/bash
|
|
|
|
me="$(readlink -f "$0")"
|
|
timeout=600
|
|
notify=$((timeout/30))
|
|
display=$(systemd-escape -- "$DISPLAY")
|
|
|
|
configure() {
|
|
xset s $((timeout - notify)) $notify
|
|
xset dpms $((timeout * 2)) $((timeout * 22 / 10)) $((timeout * 24 / 10))
|
|
}
|
|
unconfigure() {
|
|
xset s 0
|
|
xset dpms 0 0 0
|
|
}
|
|
|
|
case "$1" in
|
|
start)
|
|
configure
|
|
exec xss-lock --session=${XDG_SESSION_ID} --notifier="$me notify" --transfer-sleep-lock "$me" lock
|
|
;;
|
|
dim|notify)
|
|
echo "notify: start (idle: $(xprintidle))"
|
|
systemctl --user kill -s STOP redshift@${display}.service
|
|
trap "systemctl --user kill -s CONT redshift@${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 --current | sed -n 's/\([^ ]*\) connected .*/\1/p'))
|
|
for out in ${outputs[@]}; do
|
|
xrandr --output $out --brightness 0.2
|
|
done
|
|
sleep infinity &
|
|
wait
|
|
echo "notify: end"
|
|
;;
|
|
lock)
|
|
echo "lock: lock screen (idle: $(xprintidle))"
|
|
# Something may have mendled with screensaver settings
|
|
configure
|
|
# First, pause any music player
|
|
playerctl -a pause
|
|
# Then, lock screen
|
|
i3lock -n -e -i $HOME/.cache/i3/current-wallpaper.png -t -f
|
|
echo "lock: unlock screen"
|
|
;;
|
|
esac
|