Increase boot up time if many devices are present

This will lead to less accurate behaviour with many devices listed in
bluetoothctl devices but otherwise the script becomes unbearably slow.
Remove head from the start up process if you wish to disable this
feature
This commit is contained in:
Alexander Bocken 2020-07-25 21:43:10 +02:00
parent cbd1b2f83d
commit dfac83a064

6
bt
View File

@ -1,7 +1,8 @@
#!/bin/sh #!/bin/sh
SCAN_PERIOD=5 SCAN_PERIOD=5
AUTOTRUST=false #trust every newly paired device AUTOTRUST=false #trust every newly paired device
AUTOSCAN=true #immediately start scanning when started to speed up pairing process AUTOSCAN=false #immediately start scanning when started to speed up pairing process
#locations of blacklist and hard coded list of paired devices (watch out, need to modify Makefile as well if you want to change these values and still use make install) #locations of blacklist and hard coded list of paired devices (watch out, need to modify Makefile as well if you want to change these values and still use make install)
BLACKLIST=${XDG_DATA_HOME:-$HOME/.local/share}/bt/blacklist BLACKLIST=${XDG_DATA_HOME:-$HOME/.local/share}/bt/blacklist
PAIRLIST=${XDG_DATA_HOME:-$HOME/.local/share}/bt/paired PAIRLIST=${XDG_DATA_HOME:-$HOME/.local/share}/bt/paired
@ -75,8 +76,9 @@ startup(){
startup & startup &
update_pair_list & update_pair_list &
# include head command here to speed up launch if too many devices are listed (long uptime and long scanning will lead to this depending on your surroundings)
# shellcheck disable=SC1091 # shellcheck disable=SC1091
if bluetoothctl devices | awk '{print "bluetoothctl info "$2}' | . /dev/stdin | grep -q "Connected: yes" if bluetoothctl devices | head | awk '{print "bluetoothctl info "$2}' | . /dev/stdin | grep -q "Connected: yes"
then then
actions="$(printf "disconnect\n%s" "$actions")" actions="$(printf "disconnect\n%s" "$actions")"
fi fi