diff options
| -rw-r--r-- | .config/waybar/config.jsonc | 8 | ||||
| -rwxr-xr-x | .config/waybar/scripts/bluetooth-battery.sh | 17 | ||||
| -rw-r--r-- | .config/waybar/style.css | 7 |
3 files changed, 32 insertions, 0 deletions
diff --git a/.config/waybar/config.jsonc b/.config/waybar/config.jsonc index 0666d22..36ea502 100644 --- a/.config/waybar/config.jsonc +++ b/.config/waybar/config.jsonc @@ -14,6 +14,7 @@ "modules-right": [ "tray", "custom/gpumode", + "custom/headset-battery", "pulseaudio", "battery", "backlight", @@ -87,6 +88,13 @@ "interval": "once", "on-click": "~/.local/bin/envyswitch", }, + "custom/headset-battery": { + "exec": "~/.config/waybar/scripts/bluetooth-battery.sh", + "format": " {}", + "return-type": "json", + "interval": 15, + "hide-empty-text": true + }, "custom/cpucat": { "exec":"~/.config/waybar/scripts/catloop.sh", }, diff --git a/.config/waybar/scripts/bluetooth-battery.sh b/.config/waybar/scripts/bluetooth-battery.sh new file mode 100755 index 0000000..392d980 --- /dev/null +++ b/.config/waybar/scripts/bluetooth-battery.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash + +# Find the UPower device path for any connected headset/headphones +DEVICE_PATH=$(upower -e | grep -E 'headset|headphone' | head -n 1) + +# If no headset device is found in UPower, exit silently so Waybar hides the module +if [ -z "$DEVICE_PATH" ]; then + exit 0 +fi + +# Extract the percentage value (e.g., "90%") +PERCENTAGE=$(upower -i "$DEVICE_PATH" | awk '/percentage:/ {print $2}') + +# Output JSON format for Waybar +if [ -n "$PERCENTAGE" ]; then + printf '{"text": "%s", "tooltip": "Headset Battery: %s", "class": "connected"}\n' "$PERCENTAGE" "$PERCENTAGE" +fi diff --git a/.config/waybar/style.css b/.config/waybar/style.css index 8b2a620..e5cb0fd 100644 --- a/.config/waybar/style.css +++ b/.config/waybar/style.css @@ -105,6 +105,7 @@ window#waybar.hidden { #custom-media, #tray, #window, +#custom-headset-battery, #custom-notification, #mpd { background-color: @background; @@ -161,6 +162,12 @@ window#waybar.hidden { box-shadow: inset 0 -1px @color14; } +#custom-headset-battery { + color: @foreground; + box-shadow: inset 0 -1px @color14; +} + + @keyframes blink { to { background-color: #ffffff; |
