place 99-btautoconnect.rules at /storage/.config/udev.rules.d/
place bluetoothHandler.sh at /storage/.config
replace YOUR_BT_MAC at the udev rules config file
chmod +x bluetoothHandler.sh
udev daemon will do the autoconnect work
ACTION=="remove", SUBSYSTEMS=="input", ATTRS{name}=="YOUR_BT_MAC", RUN+="/storage/.config/bluetoothHandler.sh remove" | |
ACTION=="add", SUBSYSTEMS=="input", ATTRS{name}=="YOUR_BT_MAC", RUN+="/storage/.config/bluetoothHandler.sh add" |
#!/bin/bash | |
CARD='' | |
if [ $1 == "add" ]; then | |
CARD='PULSE:Default' | |
else | |
CARD='ALSA:@:CARD=AMLM8AUDIO,DEV=0' | |
fi | |
curl -q -H "Content-type: application/json" -X POST -d '{"jsonrpc":"2.0","id":1,1,"method":"Settings.SetSettingValue", "params":{"setting":"audiooutput.audiodevice","value":"'$CARD'"}}' http://localhost:8080/jsonrpc | |
~ | |
~ | |
~ | |
~ |