20 lines
516 B
Bash
20 lines
516 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 | sed '/^$/d') # remove empty lines
|
|
|
|
# Determine the icon
|
|
if [ -n "$bt_connected" ]; then
|
|
icon=""
|
|
else
|
|
icon=""
|
|
fi
|
|
|
|
# Output valid JSON for Waybar
|
|
echo "{\"text\": \"$icon\", \"tooltip\": $bt_connected_escaped}"
|