Created
February 22, 2023 20:51
-
-
Save overengineer/a578595dbb52a4af59dd44d2a433ffb1 to your computer and use it in GitHub Desktop.
Connect to bluetooth device
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
NAME=$1 | |
DEVICE=$(bluetoothctl devices | grep $NAME | awk '{print $2}') | |
stdbuf -oL -eL bluetoothctl connect $DEVICE 2>&1 \ | |
| tr -dc '[[:print:]]' \ | |
| xargs -I{} ~/scripts/notify-send.sh -t 1000 -f $NAME "{}" | |
success=$? | |
sleep 1 | |
if [[ $success == 0 ]]; then | |
~/scripts/notify-send.sh -t 2000 -f $NAME 'Successfully connected' | |
else | |
~/scripts/notify-send.sh -t 2000 -f $NAME 'Failed to connect' | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment