72

The most common use case I have for this is when I'm playing music over AirTunes, but don't want an open laptop laying around. Or when I'm syncing or downloading something.

This isn't the same as this question, which related to sleep vs. hibernation; I'm looking for a way to make it stay active with the lid closed.

4
  • 2
    (Answers are not likely to be MacBook Pro specific, so I'd like to also tag this with macbook, or something like laptop.)
    – Jonik
    Sep 19, 2010 at 17:53
  • 3
    by the way, keeping it awake with the lid closed is highly unadvised as it may heat up too much and damage it. that's why it doesn't have any default way to do it. with that in mind, InsomniaX is the answer.
    – cregox
    Mar 23, 2011 at 16:43
  • 1
    Additionally, you may want to look at PMSET. It is a small, native OS X application that is actually used to set all your power management settings. Moreover, the settings are persistent (they do not need to be re-applied, but will be altered if you make changes through the System Preference pane, which is actually a front-end for PMSET). While I don't see an option to address your specific concerns, nonetheless, it is an excellent utility if you wish to control more aspects of your machine: developer.apple.com/library/mac/#documentation/Darwin/Reference/…
    – user10355
    Sep 6, 2011 at 19:57
  • read through the man page of pmset or google it
    – Hawken
    Apr 23, 2012 at 21:54

9 Answers 9

48

You can use InsomniaX. It sits in your menu bar, and upon activating it, your laptop won't sleep if you close it.

8
  • 2
    InsomniaX does not work on my 2011 Macbook Pro. Is there something I am missing? (When I close the lid, it just goes into sleep mode) May 30, 2011 at 6:48
  • 1
    Does not work on 2011 Macbook Air either. Dec 21, 2011 at 12:55
  • 1
    @Legate That's interesting – people here are saying that it works for them, even though the author of the app is stating that the MBAs aren't supported.
    – Kevin Yap
    Dec 22, 2011 at 1:19
  • @KevinY Hm, that's weird. Tried it again and it didn't work. Dec 22, 2011 at 11:45
  • No evidence so far that it works with Mavericks either.
    – yurkennis
    May 21, 2014 at 19:37
19

There's also the macosx-nosleep-extension alternative to insomniaX.

3
  • 1
    Works like a charm with MBA mid 2011, Mavericks 10.9.3.
    – yurkennis
    May 21, 2014 at 19:43
  • installed the app on my MBP El Cap., after I started it, I get a dialog "ups, kernel module not found". But starting the no-sleep-prefpane and checking for an update did the trick. Works fine, thanks! Apr 9, 2016 at 23:22
  • 1
    Don't use this on macOS Sierra
    – Oion Akif
    Feb 8, 2017 at 16:19
13

Without using any third-party software, Apple says you need to have an external keyboard, mouse, or trackpad (USB or bluetooth) to prevent the computer from going to sleep (Lion), or to awaken it from sleep (Snow Leopard and earlier), after the lid is closed.

It turns out that you can apparently connect any external USB device to wake it back up from sleep. I do this with a MacBook Pro that I use with Synergy so that I can use the keyboard and mouse on my Linux workstation to control my MacBook Pro with an external monitor and the lid closed. I just plug in my USB flash drive after I close the lid to wake the MacBook Pro and then I can start using it in clamshell mode with no external keyboard or mouse connected to the MacBook Pro.

0
6

The caffeinate command line utility (built in, at least in Mavericks and Yosemite) does just this. "man caffeinate" for more

2
2

I'd gladly comment on the question, but stackexchange "rep" policies do not allow me to comment. Therefore I drafted this "answer". Please bear with me! This answer aims to prevent you from going into the wrong direction.

If you open a terminal console and enter pmset -g pslog, you see what happens when you close the lid:

mc-dondon:~ dondon$ pmset -g pslog
Logging IORegisterForSystemPower sleep/wake messages
pmset is in logging mode now. Hit ctrl-c to exit.
16.11.13 01:28:57 MEZ    
Currently drawing from 'AC Power'
 -InternalBattery-0 55%; charging; (no estimate)

16.11.13 01:29:02 MEZ    IORegisterForSystemPower: ...Sleeping...

If you google, you'll find a lot of pages which claim that pmset would do the trick. However, with respect to your question, pmset does not do the trick - at least not for me.

Neither "sudo pmset noidle" nor the often suggested "sudo pmset -a lidwake 0" will prevent the system to go to sleep when the lid is closed.

1
  • sudo pmset noidle will prevent idle sleep by creating a PM assertion while running in a terminal's session untill Control+C pressed.
    – Buktop
    Mar 4, 2017 at 20:23
1

This isn't a perfect solution IMO, but it's the closest I've found without installing a third party program.

You can completely disable sleep using sudo pmset disablesleep 1. However, after doing this you can't even manually issue the Sleep command from the Apple menu. Sleep mode becomes completely disabled.

To allow sleep once more, use sudo pmset disablesleep 0.

0

Connect an external mouse or keyboard. Close the lid, then hit a key on the keyboard or click the mouse. This wakes the laptop from sleep even if the lid is closed.

1
  • 2
    Doesn't that only apply if you also have an external display connected?
    – kchau
    Sep 22, 2010 at 20:23
0

I use Nosleep on My macbook pro. It sits in your menu bar and then you can double click it and once it turns blue, the laptop stays active when you put the lid down with the screen and backlight turning off.

1
  • I tried NoSleep on 10.10 and ran into weirdness. Sometimes the MacBook would stay awake lid-closed, sometimes it would sleep, sometimes it would run in super-slow mode. InsomniaX seems to work better. Aug 5, 2015 at 1:13
0

This is a bit hacky but doesn't require any 3rd party software.

Opening a screen sharing session will prevent the target Mac from sleeping, even when the lid is closed and it's running on battery power. I'm referring to the built-in macOS screen sharing feature you can enable in Preferences -> Sharing. Once enabled, just open the "Screen Sharing" app on another Mac, findable via Spotlight, to connect and force the other computer awake.

Screenshot of enabling Screen Sharing in Preferences

As long as the screen sharing session is open the target Mac won't sleep. I can even use this trick to wake up a sleeping Mac, that's on battery with lid closed, assuming it's still listening on wifi in some lower power mode.

You must log in to answer this question.

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