aboutsummaryrefslogtreecommitdiff
path: root/.local/bin/bcn
diff options
context:
space:
mode:
authorkrolxon <krolyxon@tutanota.com>2025-08-16 20:49:05 +0530
committerkrolxon <krolyxon@tutanota.com>2025-08-16 20:49:05 +0530
commitf3bdd21020b8e618433a06c1efc1cc665cb6839d (patch)
tree32427d47c079637b670a20b62e0339df0e248641 /.local/bin/bcn
first commit using stow
Diffstat (limited to '.local/bin/bcn')
-rwxr-xr-x.local/bin/bcn24
1 files changed, 24 insertions, 0 deletions
diff --git a/.local/bin/bcn b/.local/bin/bcn
new file mode 100755
index 0000000..1c64085
--- /dev/null
+++ b/.local/bin/bcn
@@ -0,0 +1,24 @@
+#!/bin/bash
+
+#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'} | rofi -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