Last active
April 29, 2019 00:57
-
-
Save J3698/7bd8a2deb056dc3021dcb9ae74eea853 to your computer and use it in GitHub Desktop.
New version of auto-bt.sh
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 | |
coproc stdbuf -oL bluetoothctl | |
sleep 5 | |
sudo -u pi /usr/local/bin/jackd -dalsa -r44100 -p1024 -n2 & | |
sleep 10 | |
sudo -u pi pulseaudio --start | |
echo "Started Jackd" | |
echo -e "pairable on\n" >& ${COPROC[1]} | |
echo -e "discoverable on\n" >& ${COPROC[1]} | |
echo -e "agent NoInputNoOutput\n" >& ${COPROC[1]} | |
echo -e "default-agent" >& ${COPROC[1]} | |
while true | |
do | |
read -ru ${COPROC[0]} line | |
echo $line | |
if [[ "$line" == *"Paired: yes"* ]] | |
then | |
mac=`echo $line | awk '{print $(NF-2)}'` | |
echo $mac | |
echo -e "trust $mac" >& ${COPROC[1]} | |
echo -e "connect $mac" >& ${COPROC[1]} | |
elif [[ "$line" == *"Discoverable: no"* ]] | |
then | |
echo -e "discoverable on\n" >& ${COPROC[1]} | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment