Krolyxon
Commit ace9df5

Branches

Refs →

auroraace9df5

waybar: add bluetooth battery status custom module

Author
krolyxon
Date
2026-09-19 18:48 +0530
Parent
35d4d85
Commit
ace9df58c7f7c4f5cf140f9bf17418c5947fcf5f

+32 −0

3 files changed

  1. M .config/waybar/config.jsonc +8 −0
  2. A .config/waybar/scripts/bluetooth-battery.sh +17 −0
  3. M .config/waybar/style.css +7 −0
M .config/waybar/config.jsonc View
@@ -14,6 +14,7 @@
1414 "modules-right": [
1515 "tray",
1616 "custom/gpumode",
17+ "custom/headset-battery",
1718 "pulseaudio",
1819 "battery",
1920 "backlight",
@@ -87,6 +88,13 @@
8788 "interval": "once",
8889 "on-click": "~/.local/bin/envyswitch",
8990 },
91+ "custom/headset-battery": {
92+ "exec": "~/.config/waybar/scripts/bluetooth-battery.sh",
93+ "format": "󰋋 {}",
94+ "return-type": "json",
95+ "interval": 15,
96+ "hide-empty-text": true
97+ },
9098 "custom/cpucat": {
9199 "exec":"~/.config/waybar/scripts/catloop.sh",
92100 },
A .config/waybar/scripts/bluetooth-battery.sh View
@@ -0,0 +1,17 @@
1+#!/usr/bin/env bash
2+
3+# Find the UPower device path for any connected headset/headphones
4+DEVICE_PATH=$(upower -e | grep -E 'headset|headphone' | head -n 1)
5+
6+# If no headset device is found in UPower, exit silently so Waybar hides the module
7+if [ -z "$DEVICE_PATH" ]; then
8+ exit 0
9+fi
10+
11+# Extract the percentage value (e.g., "90%")
12+PERCENTAGE=$(upower -i "$DEVICE_PATH" | awk '/percentage:/ {print $2}')
13+
14+# Output JSON format for Waybar
15+if [ -n "$PERCENTAGE" ]; then
16+ printf '{"text": "%s", "tooltip": "Headset Battery: %s", "class": "connected"}\n' "$PERCENTAGE" "$PERCENTAGE"
17+fi
M .config/waybar/style.css View
@@ -105,6 +105,7 @@ window#waybar.hidden {
105105 #custom-media,
106106 #tray,
107107 #window,
108+#custom-headset-battery,
108109 #custom-notification,
109110 #mpd {
110111 background-color: @background;
@@ -161,6 +162,12 @@ window#waybar.hidden {
161162 box-shadow: inset 0 -1px @color14;
162163 }
163164
165+#custom-headset-battery {
166+ color: @foreground;
167+ box-shadow: inset 0 -1px @color14;
168+}
169+
170+
164171 @keyframes blink {
165172 to {
166173 background-color: #ffffff;