Skip to content

Instantly share code, notes, and snippets.

@teppeis
Created April 13, 2021 13:48
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 teppeis/ea73d55ed288ff72cc5c2acf6b9d9ff9 to your computer and use it in GitHub Desktop.
Save teppeis/ea73d55ed288ff72cc5c2acf6b9d9ff9 to your computer and use it in GitHub Desktop.
# derived from https://yoshiori.hatenablog.com/entry/2021/04/13/171405
AIR_PODS_ADDRESS="aa-aa-aa-aa-aa-aa"
AIR_PODS_NAME="XXX AirPods Pro"
/usr/local/bin/bluetoothconnector -c $AIR_PODS_ADDRESS
for ((i=0 ; i<10 ; i++))
do
if [ "Connected" == "$(/usr/local/bin/bluetoothconnector -s $AIR_PODS_ADDRESS)" ]; then
# sleep 0.5
/usr/local/bin/SwitchAudioSource -s "$AIR_PODS_NAME"
sleep 0.5
afplay /System/Library/Sounds/Hero.aiff
say -v samantha Connected
break
else
echo "Not connected"
fi
sleep 1
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment