externalize config from script
This commit is contained in:
		
							
								
								
									
										10
									
								
								Makefile
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								Makefile
									
									
									
									
									
								
							@@ -1,23 +1,24 @@
 | 
			
		||||
# bthandler
 | 
			
		||||
# See LICENSE file for copyright and license details.
 | 
			
		||||
 | 
			
		||||
# install this via `make install`, not with sudo
 | 
			
		||||
# paths
 | 
			
		||||
DESTDIR = /usr/local/bin
 | 
			
		||||
DATA_DIR = ~/.config/bt#if changed, needs adjustment in bt as well (defined in the beginning)
 | 
			
		||||
SRC = bt
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
install:
 | 
			
		||||
	mkdir -p $(DESTDIR)
 | 
			
		||||
	mkdir -p $(DATA_DIR)
 | 
			
		||||
	cp -f bt $(DESTDIR)/bt
 | 
			
		||||
	chmod 755 $(DESTDIR)/bt
 | 
			
		||||
	sudo cp -f bt $(DESTDIR)/bt
 | 
			
		||||
	sudo chmod 755 $(DESTDIR)/bt
 | 
			
		||||
	touch $(DATA_DIR)/blacklist
 | 
			
		||||
	touch $(DATA_DIR)/paired
 | 
			
		||||
	touch $(DATA_DIR)/alias
 | 
			
		||||
	cp config $(DATA_DIR)/config
 | 
			
		||||
 | 
			
		||||
uninstall:
 | 
			
		||||
	rm -f $(DESTDIR)/bt
 | 
			
		||||
	sudo rm -f $(DESTDIR)/bt
 | 
			
		||||
	rm -rf $(DATA_DIR)
 | 
			
		||||
 | 
			
		||||
#clears manual paired devices list and blacklist
 | 
			
		||||
@@ -27,5 +28,6 @@ clear:
 | 
			
		||||
	touch $(DATA_DIR)/paired
 | 
			
		||||
	touch $(DATA_DIR)/blacklist
 | 
			
		||||
	touch $(DATA_DIR)/alias
 | 
			
		||||
	cp config $(DATA_DIR)/config
 | 
			
		||||
 | 
			
		||||
.PHONY: install uninstall clear
 | 
			
		||||
 
 | 
			
		||||
@@ -16,8 +16,9 @@ all via dmenu. Should be easily extendable by editing the `actions` string.
 | 
			
		||||
Edit the Makefile to reflect your preffered installation destination. Then, simply
 | 
			
		||||
 | 
			
		||||
```bash
 | 
			
		||||
sudo make install
 | 
			
		||||
make install
 | 
			
		||||
```
 | 
			
		||||
*Warning*: `sudo make install` will not install correctly. Will be fixed in the future.
 | 
			
		||||
 | 
			
		||||
Afterwards, invoking `bt` will start the menu.
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										20
									
								
								bt
									
									
									
									
									
								
							
							
						
						
									
										20
									
								
								bt
									
									
									
									
									
								
							@@ -1,20 +1,6 @@
 | 
			
		||||
#!/bin/sh
 | 
			
		||||
SCAN_PERIOD=5
 | 
			
		||||
AUTOTRUST=false #trust every newly paired device
 | 
			
		||||
AUTOSCAN=false #immediately start scanning when started to speed up pairing process
 | 
			
		||||
#If you want to update symbols in your statusbar add your details below:
 | 
			
		||||
bar="dwmblocks"
 | 
			
		||||
barsignal="4"
 | 
			
		||||
 | 
			
		||||
#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_CONFIG_HOMe:-$HOME/.config}/bt/blacklist
 | 
			
		||||
PAIRLIST=${XDG_CONFIG_HOME:-$HOME/.config}/bt/paired
 | 
			
		||||
ALIASLIST=${XDG_CONFIG_HOME:-$HOME/.config}/bt/alias
 | 
			
		||||
 | 
			
		||||
actions="$(printf 'pair\nunpair\n')"
 | 
			
		||||
#disconnect menu does not need to be displayed since just directly selecting the connected device will disconnect it
 | 
			
		||||
#set to anything non-empty to enable
 | 
			
		||||
include_disconnect_option=""
 | 
			
		||||
#load config
 | 
			
		||||
. "${XDG_CONFIG_HOME:-$HOME/.config}/bt/config"
 | 
			
		||||
 | 
			
		||||
[ "$AUTOTRUST" = false ] && actions="$(printf '%s\ntrust\n' "$actions")"
 | 
			
		||||
 | 
			
		||||
@@ -272,7 +258,7 @@ case $choice in
 | 
			
		||||
					notify-send "bt" "device not in paired-devices list, re-adding (device needs to be in pairing mode for this)"
 | 
			
		||||
					scan on
 | 
			
		||||
					echo "Scan on"
 | 
			
		||||
					sleep 5
 | 
			
		||||
					sleep $SCAN_PERIOD
 | 
			
		||||
					echo Attempting to pair...
 | 
			
		||||
					bluetoothctl pair "$dev_id"
 | 
			
		||||
					scan off
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										16
									
								
								config
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										16
									
								
								config
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,16 @@
 | 
			
		||||
SCAN_PERIOD=5
 | 
			
		||||
AUTOTRUST=false #trust every newly paired device
 | 
			
		||||
AUTOSCAN=false #immediately start scanning when started to speed up pairing process
 | 
			
		||||
#If you want to update symbols in your statusbar add your details below:
 | 
			
		||||
bar="dwmblocks"
 | 
			
		||||
barsignal="4"
 | 
			
		||||
 | 
			
		||||
#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_CONFIG_HOME:-$HOME/.config}/bt/blacklist
 | 
			
		||||
PAIRLIST=${XDG_CONFIG_HOME:-$HOME/.config}/bt/paired
 | 
			
		||||
ALIASLIST=${XDG_CONFIG_HOME:-$HOME/.config}/bt/alias
 | 
			
		||||
 | 
			
		||||
actions="$(printf 'pair\nunpair\n')"
 | 
			
		||||
#disconnect menu does not need to be displayed since just directly selecting the connected device will disconnect it
 | 
			
		||||
#set to anything non-empty to enable
 | 
			
		||||
include_disconnect_option=""
 | 
			
		||||
		Reference in New Issue
	
	Block a user