fixed pairing issue

This commit is contained in:
Alexander Bocken 2021-06-20 17:19:57 +02:00
parent dfa24a8967
commit 11689c2e22
Signed by: Alexander
GPG Key ID: 1D237BE83F9B05E8

9
bt
View File

@ -10,11 +10,9 @@ barsignal="4"
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
actions="pair actions="$(printf 'pair\nunpair\n')"
unpair"
[ "$AUTOTRUST" = false ] && actions="${actions} [ "$AUTOTRUST" = false ] && actions="$(printf '%s\ntrust\n' "$actions")"
trust"
#Checks for necessary programs to be present. Very unlikely not to be present but let's just err on the safer side. #Checks for necessary programs to be present. Very unlikely not to be present but let's just err on the safer side.
for prog in dmenu bluetoothctl awk cat date nl; do for prog in dmenu bluetoothctl awk cat date nl; do
@ -103,6 +101,7 @@ bt_IDS="$( ( bluetoothctl paired-devices && cat "$PAIRLIST" ) | sort -u | awk '{
#Compile list of all device Names of paired devices (from bluetoothctl and from hardcoded list) #Compile list of all device Names of paired devices (from bluetoothctl and from hardcoded list)
paired_devices="$( ( bluetoothctl paired-devices && cat "$PAIRLIST" ) | sort -u | awk '{for (i=3; i<NF; i++) printf $i " "; print $NF}' )" paired_devices="$( ( bluetoothctl paired-devices && cat "$PAIRLIST" ) | sort -u | awk '{for (i=3; i<NF; i++) printf $i " "; print $NF}' )"
echo "paired_devices:$paired_devices"
disp_devices="$( echo "$paired_devices" | grep -vf "$BLACKLIST" )" disp_devices="$( echo "$paired_devices" | grep -vf "$BLACKLIST" )"
@ -159,7 +158,7 @@ pair(){
bluetoothctl trust "$dev_id" bluetoothctl trust "$dev_id"
fi fi
#if device is not already hard coded as paired, add to paired devices list #if device is not already hard coded as paired, add to paired devices list
if $pair_succesful && [ "$( grep "$dev_id" "$PAIRLIST")" = "" ] || [ "$(wc -l "$PAIRLIST")" -eq 0 ] if $pair_succesful && [ "$( grep "$dev_id" "$PAIRLIST")" = "" ] || [ "$(wc -l < "$PAIRLIST")" -eq 0 ]
then then
echo to be added to "$PAIRLIST": echo to be added to "$PAIRLIST":
echo Device "$dev_id" "$choice" echo Device "$dev_id" "$choice"