There's a "Change what happens when you close the laptop lid" setting in Windows. Is there an equivalent in OS X?

In Windows one can usually choose between

  • Do nothing,
  • Sleep,
  • Hibernate.

The Macbook, however, doesn't seem to have this setting. It'll always go to sleep. I would like to set it to "Do nothing" to be able to finish downloads.


Nope, there's no such setting in OS X. This has lead to the creation of a number of sleep-prevention apps:

  • InsomniaX

    Simple app but lets you set options for each:

  • macosx-nosleep-extension

    A preference pane for enabling/disabling sleep-prevention.


You can use the command line utility pmset to change the behavior of the lid closed/open state.

To disable wake/sleep on lid state:

sudo pmset -a lidwake 0

To undo the last setting

sudo pmset -a lidwake 1

By default, closing the lid will put the Mac to sleep. Setting the lidwake 0 value will disable it meaning closing the lid will do nothing.


Steps:

  1. Connect keyboard and mouse to your macbook
  2. Connect the external display and let it be identified
  3. Connect charger
  4. Just close the lid

Works on my early 2015 macbook pro A1502 It is recommended to put your macbook to sleep before unplugging the external display.

More here > https://support.apple.com/en-in/HT201834

NOTE: I am on High Sierra, missed reading OSX while pushing the answer, but the link suggest same may work on all. Do try and leave a comment if it works!


One possible solution would be to use this pmset setting:

ttyskeepawake - prevent idle system sleep when any tty (e.g. remote login session) is 'active'. A tty is 'inactive' only when its idle time exceeds the system sleep timer. (value = 0/1)

Regarding another solution:

    sudo pmset -a lidwake 0

According to the man page, the lidwake only takes a laptop out of standby.

lidwake - wake the machine when the laptop lid (or clamshell) is opened (value = 0/1)

If doesn't say anything about staying awake when the lid closes

If the lidwake setting actually does work for you, you will likely NOT want to use the -a flag because sometime when you are out and about, you will kill your battery becuase your laptop will not go into standby.

Use the -c (charger) flag instead.

sudo pmset -c lidwake 0

Finally, type the word caffeinate on the command line and that will prevent the laptop from going into standby for as long as the terminal is open or the command is running.