Converted script to bash instead of needing zsh, cleaned up a bit.

This commit is contained in:
Alexander Bocken 2020-04-18 22:31:45 +02:00
parent 3502382e05
commit 0b9421af97
2 changed files with 12 additions and 11 deletions

View File

@ -1,10 +1,10 @@
# bthandler
# See LICENSE file for copyright and license details.
VERSION = 1.0
VERSION = 1.1
# paths
PREFIX = ~/.local/bin
PREFIX = ~/.local/bin/tools
SRC = bthandler
OBJ = $(SRC:.c=.o)

View File

@ -1,32 +1,33 @@
#!/bin/zsh
#!/bin/bash
#wait time to discover new devices in seconds
SCAN_PERIOD=5
BLACKLIST=$HOME/.local/bin/tools/bt_blacklist
IDS=$(bluetoothctl paired-devices | awk '{print $2}')
echo $IDS > /tmp/bt_IDS
Devices=$(bluetoothctl paired-devices | awk '{for (i=3; i<NF; i++) printf $i " "; print $NF}' | sed 's/ $//')
echo $Devices > /tmp/bt_devices
Blacklist='MX Master\n'
Devices=$( echo $Devices | grep -vf $BLACKLIST )
actions="\nturn off\nturn on\nscan on\npair"
choice=$( echo $Devices$actions | dmenu -p 'BT:' )
choice=$( printf "$Devices$actions" | dmenu -i -p 'What BT action would you like to perform:' )
cleanup(){
rm -f /tmp/bt_devices
rm -f /tmp/bt_IDS
rm -f /tmp/paired_devices
exit
}
case $choice in
"turn on") bluetoothctl power on
cleanup
exit;;
cleanup;;
"turn off") bluetoothctl power off
cleanup
exit;;
cleanup;;
"scan on") bluetoothctl power on && echo power on && sleep 2
st -e bluetoothctl scan on
cleanup
exit;;
cleanup;;
"pair") bluetoothctl power on
bluetoothctl scan on & disown
notify-send "Bluetooth" "Searching for devices, please wait a bit"