From 0c8fa3a2a270747f3dbb54fe8792f3f0aec997e3 Mon Sep 17 00:00:00 2001 From: Ryan Schanzenbacher Date: Mon, 3 Aug 2026 01:22:44 -0400 Subject: Initial commit: combined darwin + guix-linux home-manager flake Supersedes nix-dotfiles (darwin) and guix-dotfiles' ad-hoc nix-home-manager flake (linux). See README.md/MIGRATION.md. --- .../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.1