Skip to content

Instantly share code, notes, and snippets.

@J3698
Last active April 29, 2019 00:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save J3698/7bd8a2deb056dc3021dcb9ae74eea853 to your computer and use it in GitHub Desktop.
Save J3698/7bd8a2deb056dc3021dcb9ae74eea853 to your computer and use it in GitHub Desktop.
New version of auto-bt.sh
#!/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