#!/usr/bin/env bash 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) icon="" tooltip=null if [ -n "$bt_connected" ]; then icon="" tooltip=$(echo "$bt_connected" | jq -R -s '.') fi # Output JSON for Waybar jq -n --arg text "$icon" --argjson tooltip "$tooltip" '{text: $text, tooltip: $tooltip}'