forked from Edesem/bluetooth-connect-script
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbcn
More file actions
24 lines (19 loc) · 794 Bytes
/
bcn
File metadata and controls
24 lines (19 loc) · 794 Bytes
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
#bcn, Bluetooth Connect
device_amount=$(bluetoothctl devices | wc -l)
if [[ $device_amount = 1 ]]; then
MAC=$(bluetoothctl devices | awk {'print $2'})
[ -z $MAC ] && MAC=NoDeviceFound # Prevents accidental disconnect error
else
select=$(bluetoothctl devices | awk {'print $3'} | dmenu -l 10 -fn Monospace-15)
MAC=$(bluetoothctl devices | grep $select | awk {'print $2'})
[ -z $MAC ] && MAC=NoDeviceFound # Prevents accidental disconnect error
fi
connect=$(bluetoothctl info $MAC | grep Connected: | awk '{print $2}')
if [[ $connect = no ]]; then
notify-send "Attempting to connect to $select"
bluetoothctl connect $MAC || notify-send "Failed to Connect"
elif [[ $connect = yes ]]; then
notify-send "Attempting to disconnect $select"
bluetoothctl disconnect $MAC
fi