I'm running a setup with the latest Retina MacBook Pro, a Windows desktop and a single external monitor.

Both machines are outputting display to a HDMI switcher, which connects to the monitor. I can switch between the sources with a button on the switcher.

The problem is that everytime I switch to the Windows machine, the Mac goes to sleep since it's in clamshell mode and it has no display connected. The VPN connection I use for work on the Mac keeps disconnecting because the machine goes to sleep.

I've tried fiddling with the power saving settings and other third party programs (including Caffeine and NoSleep) that are supposed to keep the machine awake, but none worked so far.

I am running Mavericks 10.9.5 on the latest MacBook Pro model (SSD).

Any ideas on how to always keep the machine awake, even when I switch the display to the Windows desktop?

4 Answers 4


You can use caffeinate from the terminal.app.

Just open the terminal.app and type caffeinate

Without arguments it just stays awake until you ctr+C at the terminal. There are more arguments you can use in order to prevent different system components from sleeping.

  • Thanks! This seems to have solved it. I guess I have to start looking for scripts that run caffeinate smartly at startup (discriminate between AC vs non AC to run the command, etc). Or better yet'll write one of my own.
    – fauxpride
    Oct 10, 2014 at 12:37
  • You should up vote for solutions.
    – Fyrefly
    Oct 10, 2014 at 18:21
  • I've tried upvoting, it says I don't have enough reputation.
    – fauxpride
    Oct 15, 2014 at 10:52
  • With this running in a terminal, any KVM switch sleeps my M1.
    – Wyrmwood
    Aug 16, 2022 at 16:16

InsomniaX is a third party program designed to do just that: disabling the sleep mode on a Apple laptops.

The program can prevent the Mac entering sleep mode from closing the lid or just idling (or both, of course). It's also possible to disable the sleep mode as per timer, after which the sleep mode kicks in normally.

  • Hi, InsomniaX doesn't seem to work either. The machine seems to be awake, but the VPN client thinks it's not. It disconnects the session because it thinks the machine has been suspended. Would it behave like that because when I switch displays from the Mac > Windows (and back), OS X is temporarily suspending while it detects the display changes?
    – fauxpride
    Oct 10, 2014 at 12:14
  • Hmm, could be. Are there any retry-options in the VPN? Which VPN are you using?
    – Jawa
    Oct 10, 2014 at 12:28
  • I am using the Cisco AnyConnect client. Reconnection is disabled on the VPN server, so I have no control over it.
    – fauxpride
    Oct 10, 2014 at 12:35

If InsomniaX doesn't work, you could also try macosx-nosleep-extension.

Or try to restore the pre-10.7 clamshell mode behavior by running

sudo nvram boot-args=iog=0x0

and restarting. When the laptop is connected to an external display, it makes closing the lid put the laptop to sleep, and it makes the internal display stay disabled even after the lid is opened.

  • Is there a similar option that will prevent a clamshell MBP from going to sleep when it loses power? Oct 19, 2017 at 18:45

Ensure that your Macbook is plugged to the AC power adapter, that should be enough.

See also : https://support.apple.com/en-us/HT201834

  • Not really. When the display is switched to the Windows machine, it will appear as disconnected from the Mac. So the Mac assumes it is just a normal closed situation withous a display, in which it should go to sleep.
    – Fuzzy76
    Oct 3, 2017 at 6:12

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .