summaryrefslogtreecommitdiff
path: root/scripts/toggle-idle
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/toggle-idle')
-rwxr-xr-xscripts/toggle-idle12
1 files changed, 12 insertions, 0 deletions
diff --git a/scripts/toggle-idle b/scripts/toggle-idle
new file mode 100755
index 0000000..c5334bf
--- /dev/null
+++ b/scripts/toggle-idle
@@ -0,0 +1,12 @@
+#!/usr/bin/env bash
+chk_idle=$(pgrep swayidle)
+if [ -n "$chk_idle" ]; then
+ pkill swayidle && notify-send "SWAYIDLE" "Idling stopped"
+else
+ setsid -f swayidle -w \
+ timeout 600 'swaylock -f' \
+ timeout 630 'niri msg action power-off-monitors' \
+ resume 'niri msg action power-on-monitors' \
+ before-sleep 'swaylock -f' && \
+ notify-send "SWAYIDLE" "Idling started"
+fi