waybar: Improve keepawake module

Improved display - can be always-on, with toggling idle management
on-and-off on a click.
This commit is contained in:
Marty Oehme 2025-06-13 12:24:02 +02:00
parent 8e7aaef291
commit 75fcc025f9
Signed by: Marty
GPG key ID: 4E535BC19C61886E
2 changed files with 25 additions and 6 deletions

View file

@ -1,7 +1,26 @@
#!/usr/bin/env sh
USER_SV_DIR="$HOME/.local/state/service"
cmd="${1}"
if [ "$cmd" != "" ]; then
pid=$(pgrep -x swayidle)
status="idle-disabled"
if [ "$pid" != "" ]; then
status="idle-enabled"
fi
if [ "$cmd" = "start" ] || [ "$cmd" = "toggle" ] && [ "$status" = "idle-disabled" ]; then
SVDIR="$USER_SV_DIR" sv start swayidle
elif [ "$cmd" = "stop" ] || [ "$cmd" = "toggle" ] && [ "$status" = "idle-enabled" ]; then
SVDIR="$USER_SV_DIR" sv stop swayidle
fi
fi
pid=$(pgrep -x swayidle)
status="idle-disabled"
if pgrep -x swayidle >/dev/null; then
if [ "$pid" != "" ]; then
status="idle-enabled"
fi