diff --git a/Makefile b/Makefile index 3925934..2076401 100644 --- a/Makefile +++ b/Makefile @@ -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) diff --git a/bthandler b/bthandler index 1cda360..f753d5e 100755 --- a/bthandler +++ b/bthandler @@ -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 /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"