Created
March 10, 2025 06:50
-
-
Save 0xjessel/4968b16dd93bb70d19abe06facafa43b to your computer and use it in GitHub Desktop.
Script to toggle audio output between MacBook Pro speakers and JCHEN AirPods Pro
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
| #!/bin/bash | |
| # Script to toggle audio output between MacBook Pro speakers and JCHEN AirPods Pro | |
| # Requires SwitchAudioSource: brew install switchaudio-osx | |
| # Get current audio output device | |
| CURRENT_DEVICE=$(SwitchAudioSource -c) | |
| # Define device names based on your system | |
| MACBOOK_SPEAKERS="MacBook Pro Speakers" | |
| AIRPODS="JCHEN AirPods Pro" | |
| # Toggle between devices | |
| if [[ "$CURRENT_DEVICE" == "$MACBOOK_SPEAKERS" ]]; then | |
| # Currently using MacBook speakers, switch to AirPods | |
| SwitchAudioSource -s "$AIRPODS" | |
| echo "Switched to JCHEN AirPods Pro" | |
| else | |
| # Currently using something else, switch to MacBook speakers | |
| SwitchAudioSource -s "$MACBOOK_SPEAKERS" | |
| echo "Switched to MacBook Pro Speakers" | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment