From d2b62c9d6f30a0ea88b2a235cde120cd10ba332b Mon Sep 17 00:00:00 2001 From: Ryan Schanzenbacher Date: Sat, 11 Jul 2026 22:14:43 -0400 Subject: Sketchybar now, got tired of the battery issue --- .../sketchybar/bar-config/plugins/bluetooth.sh | 37 ++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100755 users/ryan/modules/sketchybar/bar-config/plugins/bluetooth.sh (limited to 'users/ryan/modules/sketchybar/bar-config/plugins/bluetooth.sh') diff --git a/users/ryan/modules/sketchybar/bar-config/plugins/bluetooth.sh b/users/ryan/modules/sketchybar/bar-config/plugins/bluetooth.sh new file mode 100755 index 0000000..80185c0 --- /dev/null +++ b/users/ryan/modules/sketchybar/bar-config/plugins/bluetooth.sh @@ -0,0 +1,37 @@ +#!/usr/bin/env bash +source "$CONFIG_DIR/colors.sh" +source "$CONFIG_DIR/icons.sh" + +CACHE="/tmp/sketchybar_${NAME}.txt" +case "$SENDER" in + mouse.entered) + [ -f "$CACHE" ] && sketchybar --set "$NAME.details" label="$(cat "$CACHE")" + sketchybar --set "$NAME" popup.drawing=on; exit 0 ;; + mouse.exited) + sketchybar --set "$NAME" popup.drawing=off; exit 0 ;; +esac + +if ! command -v blueutil >/dev/null 2>&1; then + sketchybar --set "$NAME" label="$BT_OFF" label.color=$TEXT_DIM + printf '%s' "blueutil not installed" > "$CACHE" + exit 0 +fi + +if [ "$1" = "toggle" ]; then + if [ "$(blueutil -p)" = "1" ]; then blueutil -p 0; else blueutil -p 1; fi +fi + +if [ "$(blueutil -p)" = "1" ]; then + NAMES="$(blueutil --connected 2>/dev/null | grep -o 'name: "[^"]*"' | sed 's/name: "//; s/"$//' | paste -sd , - | sed 's/,/, /g')" + COUNT="$(blueutil --connected 2>/dev/null | grep -c 'name:')" + if [ "$COUNT" -gt 0 ]; then + sketchybar --set "$NAME" label="$BT_CONNECTED" label.color=$TEXT + printf '%s' "Bluetooth on · $COUNT connected: $NAMES" > "$CACHE" + else + sketchybar --set "$NAME" label="$BT_ON" label.color=$TEXT + printf '%s' "Bluetooth on · no devices connected" > "$CACHE" + fi +else + sketchybar --set "$NAME" label="$BT_OFF" label.color=$TEXT_DIM + printf '%s' "Bluetooth off" > "$CACHE" +fi -- cgit v1.3