fix non-display of "disconnect" action. Add option to enable this

This commit is contained in:
Alexander Bocken 2021-07-02 11:28:06 +02:00
parent c262c29072
commit 0e480a3e2d
Signed by: Alexander
GPG Key ID: 1D237BE83F9B05E8

7
bt
View File

@ -12,6 +12,9 @@ PAIRLIST=${XDG_CONFIG_HOME:-$HOME/.config}/bt/paired
ALIASLIST=${XDG_CONFIG_HOME:-$HOME/.config}/bt/alias ALIASLIST=${XDG_CONFIG_HOME:-$HOME/.config}/bt/alias
actions="$(printf 'pair\nunpair\n')" actions="$(printf 'pair\nunpair\n')"
#disconnect menu does not need to be displayed since just directly selecting the connected device will disconnect it
#set to anything non-empty to enable
include_disconnect_option=""
[ "$AUTOTRUST" = false ] && actions="$(printf '%s\ntrust\n' "$actions")" [ "$AUTOTRUST" = false ] && actions="$(printf '%s\ntrust\n' "$actions")"
@ -84,7 +87,9 @@ connected_devices="$(echo "$connected_ids" | while read -r id; do
fi fi
done)" done)"
[ -z "$connected_devices" ] && actions="$(printf "disconnect\n%s" "$actions")" [ -n "$include_disconnect_option" ] &&
[ -n "$connected_devices" ] &&
actions="$(printf "disconnect\n%s" "$actions")"
#Compile list of all Bluetooth IDS of paired devices (from bluetoothctl and from hardcoded list) #Compile list of all Bluetooth IDS of paired devices (from bluetoothctl and from hardcoded list)
bt_IDS="$( ( bluetoothctl paired-devices && cat "$PAIRLIST" ) | awk '{print $2}' | sort -u )" bt_IDS="$( ( bluetoothctl paired-devices && cat "$PAIRLIST" ) | awk '{print $2}' | sort -u )"