~mil/sxmo-utils

95ac330d0b8b837b5c188d01d34ed5b01c7ec81f — Stacy Harper 8 months ago 3bb3fb6
Add a simple bluetooth menu

Signed-off-by: Stacy Harper <contact@stacyharper.net>
Signed-off-by: Maarten van Gompel <proycon@anaproy.nl>
3 files changed, 28 insertions(+), 0 deletions(-)

M scripts/core/sxmo_appmenu.sh
A scripts/core/sxmo_bluetoothmenu.sh
M scripts/core/sxmo_common.sh
M scripts/core/sxmo_appmenu.sh => scripts/core/sxmo_appmenu.sh +1 -0
@@ 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

A scripts/core/sxmo_bluetoothmenu.sh => scripts/core/sxmo_bluetoothmenu.sh +25 -0
@@ 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

M scripts/core/sxmo_common.sh => scripts/core/sxmo_common.sh +2 -0
@@ 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