Files
Arch-R/scripts/opt-system/bluetooth-setup.sh
Douglas Teles c8e7fe99e9 Add ES Tools menu scripts and gptokeyb configs (WIP)
Interactive tool scripts for EmulationStation's OPTIONS menu at /opt/system/:
system-info, wifi-setup, bluetooth-setup, performance-mode, suspend-mode,
usb-mode, factory-reset. Uses shared menu-lib.sh with fbcon rendering.

Gamepad configs: default.gptk (RetroArch), tools.gptk (menu navigation
with D-pad arrows, A=enter, B=escape).

Note: scripts need further testing on hardware — left disabled for now.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-04 17:22:49 -03:00

51 lines
1.6 KiB
Bash

#!/bin/bash
# NAME: Bluetooth
. /usr/lib/archr/menu-lib.sh
tool_init
while true; do
if systemctl is-active bluetooth &>/dev/null; then
STATUS="ON"
PAIRED=$(bluetoothctl devices Paired 2>/dev/null)
if [ -n "$PAIRED" ]; then
PAIR_INFO=""
while read -r _ mac name; do
[ -z "$mac" ] && continue
if bluetoothctl info "$mac" 2>/dev/null | grep -q "Connected: yes"; then
PAIR_INFO+=" * $name [connected]\n"
else
PAIR_INFO+=" $name\n"
fi
done <<< "$PAIRED"
fi
else
STATUS="OFF"
fi
menu_select "Bluetooth — Status: $STATUS" \
"Toggle Bluetooth" \
"Make Discoverable (60s)" || break
case "$MENU_RESULT" in
0) # Toggle
if systemctl is-active bluetooth &>/dev/null; then
systemctl stop bluetooth 2>/dev/null
msg_show "Bluetooth" "Bluetooth stopped."
else
systemctl start bluetooth 2>/dev/null
msg_show "Bluetooth" "Bluetooth started."
fi
;;
1) # Discoverable
if ! systemctl is-active bluetooth &>/dev/null; then
systemctl start bluetooth 2>/dev/null
sleep 1
fi
bluetoothctl discoverable on 2>/dev/null
bluetoothctl pairable on 2>/dev/null
msg_show "Bluetooth" "Discoverable for 60 seconds.\nPair from your device now."
bluetoothctl discoverable off 2>/dev/null
;;
esac
done