disconnects the one device if only one is paired

This commit is contained in:
Alexander Bocken 2020-07-06 12:06:41 +02:00
parent e1fe5f134a
commit 231e9bb37b
2 changed files with 7 additions and 1 deletions

View File

@ -52,3 +52,4 @@ If you have troubles with an uninstall, _additionally_ run `which bt | xargs rm`
- update bthandler internal paired devices list if something new shows up via `bluetoothctl paired-devices` not already listed in the paired devices file -> **Implemented** - update bthandler internal paired devices list if something new shows up via `bluetoothctl paired-devices` not already listed in the paired devices file -> **Implemented**
- only show disconnect option if devices are already connected -> **Implemented** - only show disconnect option if devices are already connected -> **Implemented**
- find a way to get something similar to `grep -vf` without the need of temp files. - 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

7
bt
View File

@ -172,7 +172,12 @@ case $choice in
dev_id=$( echo "$bt_IDS" | nl | grep -P "^.*$dev_no\t" | awk '{print $2}' ) dev_id=$( echo "$bt_IDS" | nl | grep -P "^.*$dev_no\t" | awk '{print $2}' )
bluetoothctl trust "$dev_id" bluetoothctl trust "$dev_id"
fi;; fi;;
"disconnect") choice=$( echo "$paired_devices" | dmenu -l 10 -i -p 'remove which paired device?') "disconnect") if [ "$( echo "$paired_devices" | wc -l )" -gt 1 ]
then
choice=$( echo "$paired_devices" | dmenu -l 10 -i -p 'remove which paired device?')
else
choice="$(paired_devices)"
fi
if [ -n "$choice" ]; then if [ -n "$choice" ]; then
dev_no=$( echo "$paired_devices" | nl | grep -P "[0-9]+\t$choice$" | awk '{print $1}') dev_no=$( echo "$paired_devices" | nl | grep -P "[0-9]+\t$choice$" | awk '{print $1}')
dev_id=$( echo "$bt_IDS" | nl | grep -P "^.*$dev_no\t" | awk '{print $2}' ) dev_id=$( echo "$bt_IDS" | nl | grep -P "^.*$dev_no\t" | awk '{print $2}' )