#!/usr/bin/env bash # {{{autogen}}} bt_connected="" while read -r _ mac name_rest; do if [ "$(bluetoothctl info "$mac" | awk '/Connected:/ {print $2}')" = "yes" ]; then bt_connected+="$name_rest\n" fi done < <(bluetoothctl devices) # icon if [ -n "$bt_connected" ]; then icon="" tooltip=$(printf "%b" "$bt_connected") else icon="" tooltip="No devices connected" fi # ALWAYS produce valid JSON printf '{"text": "%s", "tooltip": "%s"}\n' "$icon" "$tooltip"