Was displaying the wrong way round (no coffee on staying awake and coffe on automatically going to sleep), and removed some useless variable setting.
32 lines
874 B
Bash
Executable file
32 lines
874 B
Bash
Executable file
#!/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
|
|
status="idle-enabled"
|
|
elif [ "$cmd" = "stop" ] || [ "$cmd" = "toggle" ] && [ "$status" = "idle-enabled" ]; then
|
|
SVDIR="$USER_SV_DIR" sv stop swayidle
|
|
status="idle-disabled"
|
|
fi
|
|
printf "{\"text\": \"\", \"alt\": \"%s\", \"tooltip\": \"\", \"class\": \"\"}" \
|
|
"$status"
|
|
exit
|
|
fi
|
|
|
|
status="idle-disabled"
|
|
if pgrep -x swayidle >/dev/null; then
|
|
status="idle-enabled"
|
|
fi
|
|
|
|
printf "{\"text\": \"\", \"alt\": \"%s\", \"tooltip\": \"\", \"class\": \"\"}" \
|
|
"$status"
|