Skip to content
Edith

Guide

How to Keep a MacBook Awake With the Lid Closed

Three built-in ways, what each one really does, and a safer switch for closed-lid sessions.

Updated by

Get Edith

The short answer

A MacBook goes to sleep when you close the lid. macOS only skips that sleep in closed-display mode, which needs power, an external display and an external keyboard or mouse. Without those, the only way to keep a MacBook awake with the lid closed is to turn system sleep off with pmset, either by hand or with a tool that does it for you, such as Edith's keep MacBook awake with the lid closed extension, Lid Awake.

This guide walks through the three built-in options first, says plainly where each one stops working, and then shows the Lid Awake setup with its real commands. Everything here applies to Apple silicon MacBooks on macOS 14 or later.

Method 1: closed-display mode

Built into macOS

Use an external display, power and a keyboard

Apple's guide Connect an external display to MacBook Pro says you can close the lid and keep working once an external display and accessories such as a keyboard and mouse are connected. Apple's dual-display instructions add that the Mac has to be connected to power.

  1. Connect the Mac to its power adapter.
  2. Connect and power on the external display.
  3. Connect a keyboard and a mouse or trackpad.
  4. Close the lid once the external display shows your desktop.

This is the cleanest option at a desk, because nothing about your power settings changes. It does nothing for a MacBook in a bag, on a couch or on battery: unplug the display or the power and the Mac sleeps as soon as the lid is shut.

Method 2: caffeinate

caffeinate ships with every Mac and is the right tool when the lid stays open. It holds a power assertion for as long as it runs, or for as long as another command runs.

 caffeinate -d
 caffeinate -i -t 3600
 caffeinate -s
 caffeinate -i make release
 pmset -g assertions
  • -d keeps the display awake, -i stops idle sleep, and -s stops system sleep while the Mac is on AC power.
  • -t 3600 lets go after an hour. Passing a command, as in caffeinate -i make release, holds the assertion until that command exits.
  • pmset -g assertions lists every app currently holding the Mac awake, which helps when a Mac will not sleep and you do not know why.

What caffeinate does not do is keep a MacBook with no external display running once you close the lid: closing the lid still puts it to sleep. If your build or download dies the moment you shut the lid, this is why.

Method 3: pmset disablesleep

Built into macOS, undocumented

Turn system sleep off with pmset

pmset has a disablesleep setting that stops the Mac from sleeping at all, including when the lid closes. It is not listed in man pmset, so treat it as unsupported, but it has worked for years and it needs an administrator password.

 sudo pmset -a disablesleep 1
 pmset -g
 sudo pmset -a disablesleep 0

The first line turns sleep off, pmset -g shows a SleepDisabled line set to 1 while it is active, and the last line turns normal sleep back on.

Where the built-in methods fall short

  • Closed-display mode needs a desk setup. It is not an option on battery or away from a monitor.
  • caffeinate keeps an open Mac awake but does not survive a closed lid.
  • pmset disablesleep works with the lid closed, but it has no timer, no battery limit and no reminder. If you forget the second command, the Mac stays unable to sleep until you undo it, and a MacBook that cannot sleep in a bag gets hot and drains to zero.

The Edith way: Lid Awake

Lid Awake sets the same disablesleep switch through a small helper you approve once, and wraps it in the parts that are missing: a session length, a battery floor and an automatic return to normal sleep. You control it from Edith's Home card, the notch, or the ed command line.

  1. 1

    Install Lid Awake

    Install it from the Extensions page in Edith, or from the terminal.

  2. 2

    Approve the helper once

    The first time you turn it on, macOS asks you to allow Edith's background helper in System Settings, under Login Items. After that, Lid Awake changes the setting without asking for your password again.

  3. 3

    Set a battery floor

    Lid Awake pauses itself when the battery drops below the percentage you choose, so a forgotten session cannot run the battery flat. Pass off to remove the floor.

  4. 4

    Start a session

    Pick until you turn it off, 15 minutes, 30 minutes, 1 hour, 2 hours, or until the lid closes and opens again. On the command line, on prints a preview until you add --yes.

  5. 5

    Check it and turn it off

    status shows the session, the remaining time, the battery floor and the helper state. off restores normal lid-close sleep right away.

The whole flow as a script:

 ed lid-awake battery 20
 ed lid-awake on --until-lid-reopens --yes
 ed lid-awake status
 ed lid-awake off

Restore on quit is on by default, so quitting Edith puts normal lid-close sleep back. ed lid-awake restore-on-quit false --yes turns that off if you want sleep to stay disabled after Edith quits. Also by default, when Edith's battery saver is on, for example in Low Power Mode, and the Mac is on battery, Lid Awake turns itself off and comes back when you plug in or battery saver ends. The Keep awake even on low battery setting changes that.

Lid Awake or Keep Awake?

Edith has two sleep extensions and they solve different problems. Keep Awake stops idle sleep for the Mac and its display while the lid is open, much like caffeinate -d with an on and off switch. Closing the lid still sleeps the Mac. Lid Awake is the one for a closed lid. Use Keep Awake while you work at the desk, and Lid Awake for builds, downloads and agent runs that should continue after you walk away.

Common questions

Does the screen stay on with the lid closed?

No. The built-in display turns off when the lid closes. The Mac keeps running, so network transfers, builds and terminal sessions continue.

Will my Mac sleep normally afterwards?

Yes. When a session ends, hits the battery floor or you run ed lid-awake off, Lid Awake sets disablesleep back to 0. You can confirm with pmset -g.

What is a good use for this?

Long jobs you start before leaving the desk: a large download, a test suite, or coding agents working through a task list. The run coding agents overnight setup combines Lid Awake with agent and usage tracking.