| 1 | |
| 2 | # idle.sh — swayidle timeline. Edit the numbers (seconds) to taste. |
| 3 | LOCK=300 # lock after 5 min |
| 4 | SCREEN=600 # screens off after 10 min |
| 5 | SUSPEND=0 # suspend after N seconds (0 = never) |
| 6 | |
| 7 | pkill -x swayidle |
| 8 | |
| 9 | args=(-w |
| 10 | timeout $((LOCK - 15)) 'brightnessctl -s && brightnessctl -q set 30%' |
| 11 | resume 'brightnessctl -r' |
| 12 | timeout "$LOCK" 'swaylock -f' |
| 13 | timeout "$SCREEN" 'swaymsg "output * power off"' |
| 14 | resume 'swaymsg "output * power on"' |
| 15 | before-sleep 'swaylock -f' |
| 16 | after-resume 'swaymsg "output * power on"' |
| 17 | ) |
| 18 | (( SUSPEND > 0 )) && args+=(timeout "$SUSPEND" 'systemctl suspend') |
| 19 | |
| 20 | exec swayidle "${args[@]}" |