Fixes the macOS bug where audio output defaults to the built-in speaker after waking from sleep, even when external speakers or headphones are connected to the 3.5mm audio jack.
- sleepwatcher monitors system sleep/wake events
- When your Mac wakes, it triggers a script (
~/.wakeup) - The script checks to make sure an output device/3.5mm plug is occupying the headphone port.
- If something is plugged in, the script uses SwitchAudioSource to set audio output to your 3.5mm device
- A 2-second delay ensures the system is fully awake before switching
chmod +x install.sh
./install.shThe installer will:
- Install
switchaudio-osxandsleepwatchervia Homebrew (if not present) - Auto-detect your 3.5mm audio device (or prompt you to select one)
- Create the wake script and configure it to run automatically
- macOS (tested on Ventura/Sonoma on Apple Silicon Mac Mini)
- Homebrew package manager
If you need to change the audio device after installation:
-
List available devices:
SwitchAudioSource -a -t output
-
Edit the script:
nano ~/.config/audio-wake-fix/set-audio-output.sh -
Change the
DEVICE=line to match your desired output
launchctl list | grep sleepwatchercat ~/.config/audio-wake-fix/audio-wake.logSwitchAudioSource -s "External Headphones" -t outputlaunchctl unload ~/Library/LaunchAgents/com.audio-wake-fix.sleepwatcher.plist
launchctl load -w ~/Library/LaunchAgents/com.audio-wake-fix.sleepwatcher.plistChange /opt/homebrew/ paths to /usr/local/ in the scripts.
chmod +x uninstall.sh
./uninstall.sh| Path | Purpose |
|---|---|
~/.config/audio-wake-fix/set-audio-output.sh |
The wake script |
~/.config/audio-wake-fix/audio-wake.log |
Event log |
~/.wakeup |
Symlink to wake script (sleepwatcher convention) |
~/Library/LaunchAgents/com.audio-wake-fix.sleepwatcher.plist |
Auto-start sleepwatcher |
If you prefer not to install additional tools, you can use a native approach with pmset notifications, but it's less reliable. The sleepwatcher method above is the most robust solution.
Common 3.5mm audio device names on Mac Mini:
External Headphones(most common on Apple Silicon)HeadphonesBuilt-in OutputLine Out
MIT - Use freely