MacBook Pro 2017 headphone jack seems to go to sleep when the laptop is idle I have a 2017 MBP and i'm using a pair of basic Sennheiser earphones. I am finding when the laptop is idle for a period of time (I can't work out exactly how long yet) the earphone jack seems to hang up.

The only way I can get sound out of it is to unplug the earphones and plug them back in and after 2-3 seconds I get sound again.

The spec of my machine:


  MacBook Pro (13-inch, 2017, Four Thunderbolt 3 Ports)
  macOS High Sierra 10.13.6 (17G65)
  3.1 GHz Intel Core i5
  16 GB 2133 MHz LPDDR3
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'" &gt;&gt; ~/.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