Created
October 22, 2021 19:34
-
-
Save crpb/2c91cf16445b54193e9adb37da5bc1da 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 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