19 lines
574 B
Bash
19 lines
574 B
Bash
#!/usr/bin/env bash
|
|
# Collect connected devices
|
|
bt_connected=$(bluetoothctl devices | while read -r line; do
|
|
mac=$(echo "$line" | awk '{print $2}')
|
|
if [ "$(bluetoothctl info "$mac" | awk '/Connected:/ {print $2}')" = "yes" ]; then
|
|
echo "$line" | cut -d' ' -f3-
|
|
fi
|
|
done)
|
|
# Determine the icon
|
|
if [ -n "$bt_connected" ]; then
|
|
icon=""
|
|
else
|
|
icon=""
|
|
fi
|
|
# Output: main icon for Waybar, then connected devices for tooltip
|
|
echo -n "$icon"
|
|
# Pass connected device names as JSON output for Waybar tooltip
|
|
echo "$bt_connected" | jq -R -s '{output: .}'
|