diff options
| author | ckrinitsin <101062646+ckrinitsin@users.noreply.github.com> | 2023-11-27 16:05:47 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-11-27 16:05:47 +0100 |
| commit | ca90f89b55e2a63958ec1d332928c4c5f38e674b (patch) | |
| tree | d21bfbe938954a3f09bbd0b679ffa15e8c97a52b | |
| parent | f0a505f1c1232c64ef6f5e51001f0c5e1e8b7c5a (diff) | |
| download | bluetoothctl-dmenu-ca90f89b55e2a63958ec1d332928c4c5f38e674b.tar.gz bluetoothctl-dmenu-ca90f89b55e2a63958ec1d332928c4c5f38e674b.zip | |
Add script
| -rw-r--r-- | bluetooth-devices.sh | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/bluetooth-devices.sh b/bluetooth-devices.sh new file mode 100644 index 0000000..8959a79 --- /dev/null +++ b/bluetooth-devices.sh @@ -0,0 +1,25 @@ +#!/bin/zsh + +# +# 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 -i) + +# 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 |