The problem seems to be that OSX selects the wrong output device when returning from sleep mode. For me the issue is that it selects the DisplayPort audio instead of the headphone port.
I did the following to fix this:
- Install switchaudio-osx and sleepwatcher (I personaly use Homebrew for this)
brew install switchaudio-osx sleepwatcher
- Check the name of the audio output device you want to use by running
SwitchAudioSource -n
(for me this was Built-in Output
)
- create a wake-up script using the output device from step 2:
echo -e "#\!/bin/bash\n/usr/local/bin/SwitchAudioSource -s 'Built-in Output'" >> ~/.wakeup
- Set the permissions for the file
chmod 700 ~/.wakeup
- Test the script (execute the command below and let your Mac go to sleep)
/usr/local/sbin/sleepwatcher --verbose --wakeup ~/.wakeup
- Set-up the launch configuration for sleepwatcher
ln -sfv /usr/local/opt/sleepwatcher/de.bernhard-baehr.sleepwatcher-20compatibility-localuser.plist ~/Library/LaunchAgents/
launchctl load ~/Library/LaunchAgents/de.bernhard-baehr.sleepwatcher-20compatibility-localuser.plist
brew services start sleepwatcher
- Done! Now every time your machine returns from sleep the script will run and select the correct output