Krolyxon
Commit 8ddf3a1

Branches

Refs →

aurora.localbinbcn

24 lines · 802 B · Bourne Again Shell (bash)

1#!/bin/bash
2
3#bcn, Bluetooth Connect
4
5
6device_amount=$(bluetoothctl devices | wc -l)
7
8if [[ $device_amount = 1 ]]; then
9 MAC=$(bluetoothctl devices | awk {'print $2'})
10 [ -z $MAC ] && MAC=NoDeviceFound # Prevents accidental disconnect error
11else
12 select=$(bluetoothctl devices | awk {'print $3'} | fuzzel --dmenu -l 10 -fn Monospace-15)
13 MAC=$(bluetoothctl devices | grep $select | awk {'print $2'})
14 [ -z $MAC ] && MAC=NoDeviceFound # Prevents accidental disconnect error
15fi
16
17connect=$(bluetoothctl info $MAC | grep Connected: | awk '{print $2}')
18if [[ $connect = no ]]; then
19 notify-send "Attempting to connect to $select"
20 bluetoothctl connect $MAC || notify-send "Failed to Connect"
21elif [[ $connect = yes ]]; then
22 notify-send "Attempting to disconnect $select"
23 bluetoothctl disconnect $MAC
24fi