diff --git a/bt b/bt index a3c4ffa..633fee5 100755 --- a/bt +++ b/bt @@ -4,7 +4,10 @@ SCAN_PERIOD=5 #locations of blacklist and hard coded list of paired devices (watch out, need to modify Makefile as well if you want to change these values and still use make install) BLACKLIST=${XDG_DATA_HOME:-$HOME/.local/share}/bt/blacklist PAIRLIST=${XDG_DATA_HOME:-$HOME/.local/share}/bt/paired -actions='turn off\nturn on\npair\nunpair' +actions="turn off +turn on +pair +unpair" #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; do @@ -21,11 +24,10 @@ bt_IDS="$( ( bluetoothctl paired-devices && cat "$PAIRLIST" ) | sort -u | awk '{ paired_devices="$( ( bluetoothctl paired-devices && cat "$PAIRLIST" ) | sort -u | awk '{for (i=3; i /dev/null @@ -65,8 +67,8 @@ case $choice in cleanup;; "unpair") choice=$( echo "$paired_devices" | dmenu -l 10 -i -p 'remove which paired device?') if [ -n "$choice" ]; then - dev_no=$(cat -n /tmp/paired_devices | grep -E "^[0-9]*\tDevice [0-9:].* $choice$" | awk '{print $1}') - dev_id=$( echo "$bt_IDS" | nl | grep -E "$dev_no""[[:space:]]" | awk '{print $2}' ) + 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}' ) bluetoothctl remove "$dev_id" #remove device to unpair from hard coded paired devices list new_paired_list="$( grep -v "$dev_id" "$PAIRLIST" )" @@ -77,7 +79,7 @@ esac if [ -n "$choice" ]; then #echo paired_devices: "$( echo "$paired_devices" | nl )" - 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}') #echo dev_no:"$dev_no" #echo dev_id:"$dev_id"