waybar: Add keepawake module

Shows if the pc will not automatically turn off screen or suspend.
Figures this out by checking for `swayidle` process, so that is
required. Turns on suspend again on click, and uses voidlinux `sv` user
service for it, so those have to be set up.
This commit is contained in:
Marty Oehme 2025-06-12 13:38:14 +02:00
parent 7447cb3354
commit 03f85fd958
Signed by: Marty
GPG key ID: 4E535BC19C61886E
3 changed files with 28 additions and 1 deletions

View file

@ -1,8 +1,21 @@
{ {
"layer": "top", "layer": "top",
"modules-left": ["river/tags", "custom/events", "custom/vidl", "river/window"], "modules-left": ["river/tags", "custom/events", "custom/vidl", "river/window"],
"modules-center": ["clock", "custom/media"], "modules-center": ["clock", "custom/media", "custom/keepawake"],
"modules-right": ["river/mode", "custom/wireguard", "custom/archupdates", "pulseaudio", "backlight", "network", "cpu", "memory", "temperature", "tray", "battery"], "modules-right": ["river/mode", "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": ""
},
"exec": "~/.config/waybar/modules/keepawake",
"on-click": "SVDIR=~/.local/state/service sv start swayidle",
"return-type": "json",
"interval": 5
},
"custom/archupdates": { "custom/archupdates": {
"format": "{icon}", "format": "{icon}",
"format-alt": "{} {icon}", "format-alt": "{} {icon}",

View file

@ -0,0 +1,9 @@
#!/usr/bin/env sh
status="idle-disabled"
if pgrep -x swayidle >/dev/null; then
status="idle-enabled"
fi
printf "{\"text\": \"\", \"alt\": \"%s\", \"tooltip\": \"\", \"class\": \"\"}" \
"$status"

View file

@ -18,6 +18,10 @@ window#waybar.hidden {
opacity: 0.2; opacity: 0.2;
} }
.hidden {
opacity: 0;
}
#tags button { #tags button {
font-size:17px; font-size:17px;
font-weight:900; font-weight:900;
@ -70,6 +74,7 @@ window#waybar.hidden {
#custom-wireguard, #custom-wireguard,
#custom-events, #custom-events,
#custom-vidl, #custom-vidl,
#custom-keepawake,
#custom-media { #custom-media {
padding: 0 5px; padding: 0 5px;
margin: 0 5px; margin: 0 5px;