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:
parent
8e7aaef291
commit
75fcc025f9
2 changed files with 25 additions and 6 deletions
|
|
@ -1,18 +1,18 @@
|
|||
{
|
||||
"layer": "top",
|
||||
"modules-left": ["river/tags", "custom/events", "custom/vidl", "river/window"],
|
||||
"modules-center": ["clock", "custom/media", "custom/keepawake"],
|
||||
"modules-right": ["river/mode", "custom/wireguard", "custom/archupdates", "pulseaudio", "backlight", "network", "cpu", "memory", "temperature", "tray", "battery"],
|
||||
"modules-center": ["clock", "custom/media"],
|
||||
"modules-right": ["river/mode", "custom/keepawake", "custom/wireguard", "custom/archupdates", "pulseaudio", "backlight", "network", "cpu", "memory", "temperature", "tray", "battery"],
|
||||
"custom/keepawake": {
|
||||
"format": "{icon}",
|
||||
"format-alt": "{} {icon}",
|
||||
"format-alt-click": "click-right",
|
||||
"format-icons": {
|
||||
"idle-disabled": " ",
|
||||
"idle-enabled": ""
|
||||
"idle-disabled": " ",
|
||||
"idle-enabled": " "
|
||||
},
|
||||
"exec": "~/.config/waybar/modules/keepawake",
|
||||
"on-click": "SVDIR=~/.local/state/service sv start swayidle",
|
||||
"on-click": "~/.config/waybar/modules/keepawake toggle",
|
||||
"return-type": "json",
|
||||
"interval": 5
|
||||
},
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue