Skip to content

Instantly share code, notes, and snippets.

@witokondoria
Last active August 17, 2018 14:16
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save witokondoria/8f61143136dd15d0c7d72c47867dc859 to your computer and use it in GitHub Desktop.
Save witokondoria/8f61143136dd15d0c7d72c47867dc859 to your computer and use it in GitHub Desktop.
Amlogic S905 Libreelec bluetooth autoconnect udev rules
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"

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

#!/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
~
~
~
~
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment