-
-
Save bonelifer/1a37eb9a6b8ed01350cad30a51d65b5d to your computer and use it in GitHub Desktop.
First draft for adding registered bluetooth speakers or headsets to ~/.asoundrc for #osmc #kodi
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
IFS=$'\n' BLAU_OUTPUT=( $(echo "exit" |bluetoothctl |grep Device |cat -A |cut -c59-) ) | |
lines=${#BLAU_OUTPUT[@]} | |
for i in ${BLAU_OUTPUT[@]}; do addr+=(${i:0:17}); name+=(${i:18}); done | |
SKEL='pcm.PCMNAME {\n | |
type plug\n | |
slave.pcm {\n | |
type bluealsa\n | |
device "ADDRESS"\n | |
profile "a2dp"\n | |
}\n | |
hint { show on description "FULLNAME"}\n | |
}' | |
for ((i=0;i<$lines;i++)); do | |
ADDRESS=${addr[$i]} | |
FULLNAME=${name[$i]} | |
FULLNAME=${FULLNAME::-1} | |
PCMNAME=${FULLNAME//[^[:alnum:]]/} | |
echo -e $SKEL | sed -e "s/PCMNAME/$PCMNAME/g" -e "s/ADDRESS/$ADDRESS/g" -e "s/FULLNAME/$FULLNAME/g" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment