diff --git a/scripts/core/sxmo_appmenu.sh b/scripts/core/sxmo_appmenu.sh index 2240517..5028366 100755 --- a/scripts/core/sxmo_appmenu.sh +++ b/scripts/core/sxmo_appmenu.sh @@ -401,6 +401,7 @@ programchoicesinit() { $icon_phn Dialer ^ 0 ^ sxmo_modemdial.sh $icon_msg Texts ^ 0 ^ sxmo_modemtext.sh $icon_usr Contacts ^ 0 ^ sxmo_contactmenu.sh + $(command -v bluetoothctl >/dev/null && echo "$icon_bth Bluetooth ^ 0 ^ sxmo_bluetoothmenu.sh") $(command -v megapixels >/dev/null && echo "$icon_cam Camera ^ 0 ^ GDK_SCALE=2 megapixels") $icon_net Networks ^ 0 ^ sxmo_networks.sh $icon_mus Audio ^ 0 ^ sxmo_appmenu.sh audioout diff --git a/scripts/core/sxmo_bluetoothmenu.sh b/scripts/core/sxmo_bluetoothmenu.sh new file mode 100755 index 0000000..5591684 --- /dev/null +++ b/scripts/core/sxmo_bluetoothmenu.sh @@ -0,0 +1,25 @@ +#!/usr/bin/env sh + +devicemenu() { + while true; do + DEVICES="$(bluetoothctl devices | awk '{ $1=""; printf $2; $2=""; printf " ^" $0 "\n" }')" + ENTRIES="$(echo "$DEVICES" | sed 's|.* ^ ||' | xargs -0 printf "Close Menu\nDisconnect\n%s")" + + PICKED="$( + echo "$ENTRIES" | + sxmo_dmenu_with_kb.sh -i -c -l 10 -p "Devices" + )" + + if echo "$PICKED" | grep -q "Close Menu"; then + exit + elif echo "$PICKED" | grep -q "Disconnect"; then + st -e sh -c "bluetoothctl disconnect; sleep 1" + continue + else + devicemac="$(echo "$DEVICES" | grep " \^ $PICKED$" | sed 's| ^ .*||' )" + st -e sh -c "bluetoothctl connect $devicemac; sleep 1" + fi + done +} + +devicemenu diff --git a/scripts/core/sxmo_common.sh b/scripts/core/sxmo_common.sh index 1b2e06f..becf585 100644 --- a/scripts/core/sxmo_common.sh +++ b/scripts/core/sxmo_common.sh @@ -226,6 +226,8 @@ icon_chk="" icon_and="" # shellcheck disable=SC2034 icon_wif="" +# shellcheck disable=SC2034 +icon_bth="" #allow the user to override icons if [ -x "$XDG_CONFIG_HOME/sxmo/hooks/icons" ]; then