From b5c496e8f75d0515dd4738fd9ea5cfb2ee0d1cf6 Mon Sep 17 00:00:00 2001 From: Alexander Bocken Date: Sun, 19 Dec 2021 17:42:53 +0100 Subject: [PATCH] do not print misread into paired devices list --- bt | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/bt b/bt index 9261497..30a5b1d 100755 --- a/bt +++ b/bt @@ -37,6 +37,10 @@ update_pair_list(){ btctl_paired_devices="$(bluetoothctl paired-devices)" if [ -n "$btctl_paired_devices" ] then + #do not modify files when issues occur + if echo "$btctl_paired_devices" | grep -q "No default controller available"; then + return + fi #needs temp var as it writes into the same file as it reads from btctl_not_in_list="$( echo "$btctl_paired_devices" | grep -vf "$PAIRLIST")" [ -n "$btctl_not_in_list" ] && echo "$btctl_not_in_list" >> "$PAIRLIST" @@ -141,17 +145,16 @@ pair(){ [ "$sleep_period" -gt 1 ] && plural="s" notify-send "bt" "Searching for devices, please wait $sleep_period second$plural" sleep "$sleep_period" + unset plural fi all_devices="$( bluetoothctl devices )" if [ "$paired_devices" = "" ]; then new_devices="$( echo "$all_devices" | awk '{for (i=3; i /tmp/paired_devices$$ filtered_devices="$( echo "$all_devices" | grep -v "$paired_devices")" bt_IDS="$( echo "$filtered_devices" | awk '{print $2}' )" new_devices="$( echo "$filtered_devices" | awk '{for (i=3; i