#!/usr/bin/env bash
# Genmon bluetooth applet — PNG icon + status, click opens blueman-manager.
# Replaces blueman's StatusNotifier tray icon (which the panel renders too small);
# blueman-applet still runs headless for the agent — see bin/panel/install.sh.
NEXUS_ROOT="$(cd "$(dirname "$(realpath "$0")")/../.." && pwd)"
ICON_DIR="$NEXUS_ROOT/assets/panel-icons"
powered=$(bluetoothctl show 2>/dev/null | awk -F': ' '/Powered:/{print $2; exit}')
connected=$(bluetoothctl devices Connected 2>/dev/null | grep -c '^Device')
if [ "$powered" != "yes" ]; then
echo "
${ICON_DIR}/bluetooth-disabled.png"
echo "Bluetooth: off"
elif [ "$connected" -gt 0 ]; then
names=$(bluetoothctl devices Connected 2>/dev/null | sed 's/^Device [0-9A-F:]* //')
echo "
${ICON_DIR}/bluetooth-active.png"
echo "Bluetooth: connected
${names}"
else
echo "
${ICON_DIR}/bluetooth-online.png"
echo "Bluetooth: on (no devices connected)"
fi
echo "blueman-manager"