Update toggle-idle to use hypridle

This commit is contained in:
ItsDrike 2024-02-19 01:56:00 +01:00
parent 59c3b49d33
commit c2564684da
Signed by: ItsDrike
GPG key ID: FA2745890B7048C0

View file

@ -1,9 +1,18 @@
#!/bin/sh
#!/bin/bash
set -euo pipefail
if pgrep swayidle >/dev/null; then
killall swayidle
notify-send "Idle" "Idle timeouts disabled"
idleprog="hypridle" # or swayidle
pid="$(pidof "$idleprog" || true)"
if [ -n "$pid" ]; then
# is process suspended?
if ps -o stat= -p "$pid" | grep T >/dev/null; then
kill -CONT "$pid"
notify-send "Idle-Toggle" "Idle timeouts enabled"
else
swayidle & disown
notify-send "Idle" "Idle timeouts enabled"
kill -STOP "$pid"
notify-send "Idle-Toggle" "Idle timeouts disabled"
fi
else
notify-send "Idle-Toggle" "$idleprog not running!"
fi