toggle-idle (380B)
1 #!/usr/bin/env bash 2 chk_idle=$(pgrep swayidle) 3 if [ -n "$chk_idle" ]; then 4 pkill swayidle && notify-send "SWAYIDLE" "Idling stopped" 5 else 6 setsid -f swayidle -w \ 7 timeout 600 'swaylock -f' \ 8 timeout 630 'niri msg action power-off-monitors' \ 9 resume 'niri msg action power-on-monitors' \ 10 before-sleep 'swaylock -f' && \ 11 notify-send "SWAYIDLE" "Idling started" 12 fi