summaryrefslogtreecommitdiff
path: root/common/home/scripts/bluemenu
blob: c27a859d1c5b8fe1533bb7029db4acbfcefabff0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/bin/sh

dev=$(bluetoothctl devices | sed -e 's/Device \(..:..:..:..:..:..\) \(.*\)/\2|\1/g' | column -t -s '|' | while read -r device
do
	id=$(echo "$device" | grep -o '..:..:..:..:..:..')
	if bluetoothctl info "$id" | grep Connected | grep yes > /dev/null; then
		printf " 󰂱 "
	else
		printf "   "
	fi
	echo " $device"
done | wofi --dmenu | grep -o '..:..:..:..:..:..')

[ -z "$dev" ] && exit

name=$(bluetoothctl info "$dev" | grep Name: | sed 's/^\s*Name:\s*//g')

if bluetoothctl info "$dev" | grep Connected | grep yes > /dev/null; then
	bluetoothctl disconnect "$dev"
	dunstify "Bluetooth" "Disconnected $name"
else
	bluetoothctl connect "$dev"
	dunstify "Bluetooth" "Connected $name"
fi