add bt-connect.sh script that will repeatedly attempt to connect to

a bluetooth device.
master
Alex 2023-01-08 13:36:35 -06:00
parent dbb7cd3678
commit cbddc8b676
1 changed files with 27 additions and 0 deletions

27
bt-connect.sh Executable file
View File

@ -0,0 +1,27 @@
#!/bin/sh
quit() {
QUIT="TRUE"
echo "SIG HANDLED"
}
trap 'quit' 2
trap 'quit' 15
[ $# -lt 1 ] && echo "input bluetooth device uuid to repeatedly attempt to connnect to as 1st arg" && exit
UUID="$1"
while [ -z "$QUIT" ]
do
IS_CONN="$( bluetoothctl devices Paired | grep "$UUID")"
if [ -z "$IS_CONN" ]; then
bluetoothctl connect "$UUID"
fi
sleep 5
done
echo "SCRIPT CLOSED"