only show disconnect option if devices are connected
This commit is contained in:
parent
04182df41c
commit
96d6f631d1
11
bt
11
bt
@ -6,8 +6,7 @@ AUTOTRUST=false
|
|||||||
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="disconnect
|
actions="pair
|
||||||
pair
|
|
||||||
unpair"
|
unpair"
|
||||||
|
|
||||||
[ "$AUTOTRUST" = false ] && actions="${actions}
|
[ "$AUTOTRUST" = false ] && actions="${actions}
|
||||||
@ -52,12 +51,20 @@ update_pair_list(){
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#start scanning as early as possible to speed up pairing process
|
#start scanning as early as possible to speed up pairing process
|
||||||
#=> maybe use an option to do this? Otherwise ever invocation of bt powers on the controller.
|
#=> maybe use an option to do this? Otherwise ever invocation of bt powers on the controller.
|
||||||
power on
|
power on
|
||||||
scan on
|
scan on
|
||||||
update_pair_list &
|
update_pair_list &
|
||||||
|
|
||||||
|
# shellcheck disable=SC1091
|
||||||
|
if bluetoothctl devices | awk '{print "bluetoothctl info "$2}' | . /dev/stdin | grep -q "Connected: yes"
|
||||||
|
then
|
||||||
|
actions="$(printf "disconnect\n%s" "$actions")"
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
#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" ) | sort -u | awk '{print $2}' )"
|
bt_IDS="$( ( bluetoothctl paired-devices && cat "$PAIRLIST" ) | sort -u | awk '{print $2}' )"
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user