summary refs log tree commit diff stats
path: root/bin/bluetooth-devices
diff options
context:
space:
mode:
authorChristian Krinitsin <christian@krinitsin.xyz>2024-03-16 21:16:28 +0100
committerChristian Krinitsin <christian@krinitsin.xyz>2024-03-16 21:16:28 +0100
commite992c3c164e9bf8869fb8b20eaa17ca595d92aac (patch)
tree849e0f16837e5aa269fc136512e153ec3b889de6 /bin/bluetooth-devices
parentb8a4392c8754a56265701f97f4833b447efff29a (diff)
downloaddotfiles-e992c3c164e9bf8869fb8b20eaa17ca595d92aac.tar.gz
dotfiles-e992c3c164e9bf8869fb8b20eaa17ca595d92aac.zip
custom bins
Diffstat (limited to 'bin/bluetooth-devices')
-rwxr-xr-xbin/bluetooth-devices25
1 files changed, 25 insertions, 0 deletions
diff --git a/bin/bluetooth-devices b/bin/bluetooth-devices
new file mode 100755
index 0000000..5cc4876
--- /dev/null
+++ b/bin/bluetooth-devices
@@ -0,0 +1,25 @@
+#!/bin/sh
+
+#
+# This program lists all paired devices which you can select from, the selected one
+# will be connected
+#   
+
+# Opens dmenu prompt, which lets you decide which device you want to connect to
+DEVICE=$(bluetoothctl devices | sed 's/[^ ]* //' | sed 's/[^ ]* //' | dmenu)
+
+# If dmenu was cancelled, exit program
+if [ $? -ne 0 ]; then
+    exit 1
+fi
+
+# Get MAC adress of the device you selected
+MAC=$(bluetoothctl devices | grep "$DEVICE" | sed 's/[^ ]* //' | cut -d ' ' -f1)
+
+# Send a notify whether the connection was successful 
+if bluetoothctl connect $MAC | grep -q 'successful' 
+then
+    notify-send -t 5000 -r 2954 -u normal "  Connected successfully to" "     $DEVICE"
+else 
+    notify-send -t 5000 -r 2954 -u normal "  Couldn't connect to" "     $DEVICE"
+fi