yay we can now just read a file, no need for a stupid Refresh entry

anymore
This commit is contained in:
speedie 2023-05-07 03:38:47 +02:00
parent 61603309f7
commit 6834e34b9d

View file

@ -24,18 +24,25 @@ LIST_OPTIONS() { SELDEVICE_ACTION="$(printf -- "<b>Options</b>\nConnect\nDisconn
ABOUT() { printf -- "speedwm-btctrl\nspmenu bluez frontend\n\nVersion %s\n" "$([ -e "/usr/share/speedwm/speedwm-extras-version" ] && cat /usr/share/speedwm/speedwm-extras-version || printf "1.9")" | $RUNLAUNCHER -l 40 -g 1 -p 'About'; pkill bluetoothctl; exit 0; }
SEND_NOTIF() { [ "$NOTIF_SYSTEM" = "dnote" ] && command -v dnote && [ ! -z "$*" ] && printf "$2\n" | dnote -loc 4 && exit 1 || command -v notify-send && notify-send "$1" "$2" > /dev/null; }
LIST_BT() {
printf "$(bluetoothctl devices | cut -d\ -f3-)\n\nAbout\nExit" > /tmp/btctrl-file
sleep 3
LIST_BT
}
# Enable bluetooth and scan for devices
ENABLE_BT() {
bluetoothctl power on > /dev/null && printf "Power: On\n"
bluetoothctl scan on & # Start scanning for devices
bluetoothctl devices | grep -q "No default controller" && printf "No Bluetooth controller was found.\n" && exit 1
SELDEVICE="$(printf "$(bluetoothctl devices | cut -d\ -f3-)\n\nRefresh\nAbout\nExit" | $RUNLAUNCHER -l 12 -g 1 -p "Select a device")"
LIST_BT &
SELDEVICE="$($RUNLAUNCHER -lf /tmp/btctrl-file -l 12 -g 1 -p "Select a device")"
# Check what to do
case "$SELDEVICE" in
"") exit 0 ;;
"Refresh") ENABLE_BT ;;
"Exit") exit 0 ;;
"About") ABOUT ;;
esac