smarter scanning period in re-pairing mode

This commit is contained in:
Alexander Bocken 2021-07-04 15:49:08 +02:00
parent 1223574c2b
commit 2fb43032b7
Signed by: Alexander
GPG Key ID: 1D237BE83F9B05E8

10
bt
View File

@ -263,9 +263,15 @@ case $choice in
all_devices="$(bluetoothctl devices | cut -d' ' -f2)" all_devices="$(bluetoothctl devices | cut -d' ' -f2)"
if ! echo "$dev_id" | grep -q "$all_devices"; then if ! echo "$dev_id" | grep -q "$all_devices"; then
scan on scan on
start_scan="$(cat /tmp/bt_start_scan$$)"
echo "Scan on" echo "Scan on"
notify-send "bt" "Scanning for new devices..." notify-send "bt" "Scanning for new devices until wanted device has been found"
sleep "$SCAN_PERIOD" while ! echo "$dev_id" | grep -q "$all_devices"; do
sleep 1
all_devices="$(bluetoothctl devices | cut -d' ' -f2)"
time_scanned="$(( $(date +'%s') - start_scan ))"
[ "$time_scanned" -gt 30 ] && exit 1
done
fi fi
echo Attempting to pair... echo Attempting to pair...
bluetoothctl pair "$dev_id" bluetoothctl pair "$dev_id"