From ace9df58c7f7c4f5cf140f9bf17418c5947fcf5f Mon Sep 17 00:00:00 2001 From: krolyxon Date: Sat, 19 Sep 2026 18:48:12 +0530 Subject: waybar: add bluetooth battery status custom module --- .config/waybar/scripts/bluetooth-battery.sh | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100755 .config/waybar/scripts/bluetooth-battery.sh (limited to '.config/waybar/scripts') 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 -- cgit v1.2.3