.
675 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | BCN
2 | Bluetooth connect/disconnect shell script
3 | A shell script that connects and disconnects bluetooth devices using dmenu.
4 |
5 | Requires dmenu, however if you wanted to use something else like rofi I assume it would be very trivial to change it to that or even make it cli.
6 |
7 | ##
8 |
9 |
10 |
11 |
12 |
13 | ### Install
14 | ```
15 | sudo curl -sL "https://raw.githubusercontent.com/Edesem/bluetooth-connect-script/main/bcn" -o /usr/local/bin/bcn
16 | sudo chmod +x /usr/local/bin/bcn
17 | ```
18 |
19 | ### Usage
20 | Open dmenu and type bcn, it will then show a list of previously connected bluetooth devices and hitting enter with attempt to connect to that bluetooth device.
21 |
22 | ### Update
23 | Just redo the curl command
24 |
25 | ### Unistall
26 | `sudo rm /usr/local/bin/bcn`
27 |
28 | ### License
29 | [GPL 3.0](https://raw.githubusercontent.com/Edesem/bluetooth-connect-script/main/LICENSE)
30 |
--------------------------------------------------------------------------------
/bcn:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | #bcn, Bluetooth Connect
4 |
5 |
6 | device_amount=$(bluetoothctl devices | wc -l)
7 |
8 | if [[ $device_amount = 1 ]]; then
9 | MAC=$(bluetoothctl devices | awk {'print $2'})
10 | [ -z $MAC ] && MAC=NoDeviceFound # Prevents accidental disconnect error
11 | else
12 | select=$(bluetoothctl devices | awk {'print $3'} | dmenu -l 10 -fn Monospace-15)
13 | MAC=$(bluetoothctl devices | grep $select | awk {'print $2'})
14 | [ -z $MAC ] && MAC=NoDeviceFound # Prevents accidental disconnect error
15 | fi
16 |
17 | connect=$(bluetoothctl info $MAC | grep Connected: | awk '{print $2}')
18 | if [[ $connect = no ]]; then
19 | notify-send "Attempting to connect to $select"
20 | bluetoothctl connect $MAC || notify-send "Failed to Connect"
21 | elif [[ $connect = yes ]]; then
22 | notify-send "Attempting to disconnect $select"
23 | bluetoothctl disconnect $MAC
24 | fi
25 |
--------------------------------------------------------------------------------
/bcn.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Edesem/bluetooth-connect-script/943e00f37e6bf6fc9d094a7a64f3c5437bb0e9cb/bcn.gif
--------------------------------------------------------------------------------