Skip to content

Instantly share code, notes, and snippets.

@redaphid
Created January 21, 2026 22:20
Show Gist options
  • Select an option

  • Save redaphid/62967e709e4bfb6bef5803d8bcd72577 to your computer and use it in GitHub Desktop.

Select an option

Save redaphid/62967e709e4bfb6bef5803d8bcd72577 to your computer and use it in GitHub Desktop.
Toggle macOS audio between headphones and built-in speakers/mic
#!/bin/bash
# Toggle between MOMENTUM 4 and MacBook Pro built-in audio
command -v SwitchAudioSource &>/dev/null || { echo "Error: run 'brew install switchaudio-osx' first" >&2; exit 1; }
if [[ "$(SwitchAudioSource -c)" == "MOMENTUM 4" ]]; then
SwitchAudioSource -s "MacBook Pro Speakers"
SwitchAudioSource -t input -s "MacBook Pro Microphone"
else
SwitchAudioSource -s "MOMENTUM 4"
SwitchAudioSource -t input -s "MOMENTUM 4"
fi
osascript -e "display notification \"$(SwitchAudioSource -c)\" with title \"Audio\""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment