hypr-dotfiles/hypr/scripts/idle-inhibit-toggle.sh
Jeena de7375bfb7 Add idle-inhibit
Sometimes I don't want the computer to go to sleep bacause I'm
running something in the background. for that I always used
systemd-inhibit sleep 999999 manually on the terminal, but I want
it to be easy to use without remembering the whole command every
time.

Therefor I added a custom button to waybar which does that for me.
2025-12-13 14:27:09 +09:00

13 lines
335 B
Bash
Executable file

#!/usr/bin/env bash
PIDFILE="$XDG_RUNTIME_DIR/idle-inhibit.pid"
if [[ -f "$PIDFILE" ]] && kill -0 "$(cat "$PIDFILE")" 2>/dev/null; then
kill "$(cat "$PIDFILE")"
rm -f "$PIDFILE"
echo "off"
else
systemd-inhibit --what=idle:sleep --why="Manual Waybar inhibit" sleep infinity &
echo $! > "$PIDFILE"
echo "on"
fi