removed files from master branch

This commit is contained in:
Alexander Bocken 2020-06-08 22:11:58 +02:00
parent 9d730c0a84
commit f01eeeb67b
4 changed files with 0 additions and 186 deletions

21
LICENSE
View File

@ -1,21 +0,0 @@
MIT License
Copyright (c) 2020 Alexander Bocken
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@ -1,31 +0,0 @@
# bthandler
# See LICENSE file for copyright and license details.
VERSION = 1.1
# paths
PREFIX = ~/.local/bin
DATA_DIR = ~/.local/share/bt#if changed, needs adjustment in bt as well (defined in the beginning)
SRC = bt
install:
mkdir -p $(DESTDIR)$(PREFIX)
mkdir -p $(DATA_DIR)
cp -f bt $(DESTDIR)$(PREFIX)
chmod 755 $(DESTDIR)$(PREFIX)/bt
touch $(DATA_DIR)/blacklist
touch $(DATA_DIR)/paired
uninstall:
rm -f $(DESTDIR)$(PREFIX)/bt
rm -rf $(DATA_DIR)
#clears manual paired devices list and blacklist
clear:
rm -rf $(DATA_DIR)
mkdir -p $(DATA_DIR)
touch $(DATA_DIR)/paired
touch $(DATA_DIR)/blacklist
.PHONY: install uninstall clear

View File

@ -1,42 +0,0 @@
# bthandler
A simple interactive tool to:
- connect to already paired devices
- pair new ones
- unpair already paired devices
- turn bluetooth on/off
- blacklist paired devices to not be listed in connection selection (useful for auto-connecting devices like some mice)
all via dmenu. Should be easily extendable by editing the `actions` string.
# Installation
Edit the Makefile to reflect your preffered installation destination. Then, simply
```bash
make install
```
# Clear blacklist/pairlist
Since `bluetoothctl paired-devices` seems to be hugely unreliable in listing paired devices, bthandler has a seperate list for all paired devices through bthandler.
There is also a blacklist available to not display certain devices, which might be useful for autoconnection Bluetooth mice for example.
To clear these files, simply run
```bash
make clear
```
and these files will be reset to their inital, empty state.
# Uninstall
To uninstall you might follow that it's a simple
```bash
make uninstall
```
# Pending features
Here's a growing list of features that are not yet actively worked on but might be nice in the future. Currently I'm more concerned with reliability that fulfilling feature requests, but I'm still open to put some on this list.
- start scanning for new devices immediately at execution to save time when pairing new devices
- auto-trust newly paired devices/trust device via dmenu
- blacklist devices via dmenu

92
bt
View File

@ -1,92 +0,0 @@
#!/bin/bash
#wait time to discover new devices in seconds
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
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
if ! hash "$prog" 2>/dev/null; then
printf 'bthandler: %s: command not found\n' "$prog" >&2
exit 127
fi
done
#Compile list of all Bluetooth IDS of paired devices (from bluetoothctl and from hardcoded list)
bt_IDS="$( ( bluetoothctl paired-devices && cat "$PAIRLIST" ) | sort -u | awk '{print $2}' )"
#Compile list of all device Names of paired devices (from bluetoothctl and from hardcoded list)
paired_devices="$( ( bluetoothctl paired-devices && cat "$PAIRLIST" ) | sort -u | awk '{for (i=3; i<NF; i++) printf $i " "; print $NF}' )"
disp_devices="$( echo "$paired_devices" | grep -vf "$BLACKLIST" )"
#Don't print empty device list, removes unnecessary empty choice in dmenu
[ "$disp_devices" = "" ] && choice=$( echo "$actions" | dmenu -i -p 'What BT action would you like to perform:' )
[ "$disp_devices" != "" ] && choice=$( echo "$disp_devices" "$actions" | dmenu -i -p 'What BT action would you like to perform:' )
cleanup(){
bluetoothctl scan off > /dev/null
exit 0
}
case $choice in
"turn on") bluetoothctl power on
cleanup;;
"turn off") bluetoothctl power off
cleanup;;
"scan on") bluetoothctl power on && echo power on && sleep 2
([ -n "$TERMINAL" ] && $TERMINAL -e bluetoothctl scan on ) || st bluetoothctl scan on
cleanup;;
"pair") bluetoothctl power on
bluetoothctl scan on & disown
notify-send "Bluetooth" "Searching for devices, please wait a bit"
sleep $SCAN_PERIOD
echo "$paired_devices" > /tmp/paired_devices
new_devices="$( bluetoothctl devices | awk '{for (i=3; i<NF; i++) printf $i " "; print $NF}' | grep -vf /tmp/paired_devices )"
rm -f /tmp/paired_devices
choice=$( echo "$new_devices" | dmenu -l 10 -i -p 'pair with which device?' )
if [ -n "$choice" ]; then
bt_IDS="$( bluetoothctl devices | awk '{print $2}' )"
dev_no=$( echo "$new_devices" | nl | grep "$choice" | awk '{print $1}')
dev_id=$( echo "$bt_IDS" | nl | grep -P "^.*$dev_no\t" | awk '{print $2}' )
bluetoothctl pair "$dev_id" && sleep 2
bluetoothctl connect "$dev_id"
#if device is not already hard coded as paired, add to paired devices list
#echo grep: "$( grep "$dev_id" "$PAIRLIST" )"
if grep -q "$dev_id" "$PAIRLIST"
then
echo Device "$dev_id" "$choice" >> "$PAIRLIST"
fi
fi
cleanup;;
"unpair") choice=$( echo "$paired_devices" | dmenu -l 10 -i -p 'remove which paired device?')
if [ -n "$choice" ]; then
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" )"
echo "$new_paired_list" > "$PAIRLIST"
fi
cleanup;;
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_id=$( echo "$bt_IDS" | nl | grep -P "^.*$dev_no\t" | awk '{print $2}')
#echo dev_no:"$dev_no"
#echo dev_id:"$dev_id"
#echo choice:"$choice"
bluetoothctl power on
bluetoothctl pair "$dev_id"
bluetoothctl connect "$dev_id"
fi
cleanup