selecting connected device disconnects it

This commit is contained in:
Alexander Bocken 2020-07-23 20:47:11 +02:00
parent 3a0fabef13
commit cbd1b2f83d
2 changed files with 8 additions and 2 deletions

View File

@ -62,3 +62,4 @@ This should only be an issue if `bluetoothctl scan off` is unreliable for you th
- find a way to get something similar to `grep -vf` without the need of temp files.
- only list connected devices to disconnect from, not all paired devices -> **Implemented**
- only list not trusted devices in trust menu -> **Implemented**
- selecting already connected device disconnects it -> **Implemented**

9
bt
View File

@ -221,8 +221,13 @@ case $choice in
[ "$dev_no" != "" ] && dev_id=$( echo "$bt_IDS" | nl | grep -P "^.*$dev_no\t" | awk '{print $2}')
if [ -n "$dev_id" ]; then
power on
bluetoothctl devices | grep -q "$dev_id" || bluetoothctl pair "$dev_id"
bluetoothctl connect "$dev_id"
if bluetoothctl info "$dev_id" | grep -q "Connected: yes"
then
bluetoothctl disconnect "$dev_id"
else
bluetoothctl devices | grep -q "$dev_id" || bluetoothctl pair "$dev_id"
bluetoothctl connect "$dev_id"
fi
fi;;
esac