💻 Lid-closed how-to
How to keep your Mac awake, even when your MacBook lid is closed
Closing the lid is not an idle timeout - it is a hardware-level sleep, which is why caffeinate does nothing here. Below: the three real methods, the commands, the catches, and the one toggle that does it without any of this.
Free 14-day trial · one-time $39.99 · no telemetry · macOS 13+
First: why your usual trick didn't work
Almost everyone tries caffeinate first, shuts the lid, and finds the Mac asleep anyway. That is not a bug and it is not your flags.
caffeinate - and every "amphetamine-style" menu-bar app - creates a power assertion that blocks idle sleep: the sleep that happens because you walked away from the keyboard. Closing the lid is a different event entirely. macOS treats the lid switch at the hardware/firmware level and sleeps the machine directly, and an idle-sleep assertion has no say in it.
The consequence: to survive a lid close you either need Apple's official clamshell setup, or something that flips the system's sleep-disable flag - a different, much blunter mechanism. Those are the only two doors.
1. Clamshell mode (Apple's official, guaranteed way)
Clamshell mode is the supported way to run a MacBook with the lid shut. It is completely reliable - it just has a hardware bill.
- Plug in power. Connect the Mac to its charger or a powered dock. On battery alone, clamshell will not hold.
- Connect an external display. HDMI, USB-C or Thunderbolt. This is the part with no workaround - no display, no clamshell.
- Connect an external keyboard or mouse. Wired, or Bluetooth (make sure "Allow Bluetooth devices to wake this computer" is on in Settings).
- Close the lid. The Mac keeps running and the external display takes over. Press a key on the external keyboard if the screen does not come back.
The catch: you have to carry a monitor, a keyboard and a charger. That is fine at a desk and useless the moment you are on the move - in a cafe, on a train, or with the Mac in your bag. It also means clamshell can never help you if the whole point is to walk away with the machine.
2. sudo pmset -a disablesleep 1 (powerful, and easy to regret)
The blunt instrument. This sets a system-wide flag that tells macOS not to sleep at all - including on lid close. It needs root, and it stays set until you clear it.
# Disable sleep system-wide (survives a lid close on many Apple Silicon Macs)
sudo pmset -a disablesleep 1
# Check whether it is currently set (1 = sleep disabled, 0 = normal)
pmset -g | grep SleepDisabled
# Put it back to normal - do NOT forget this one
sudo pmset -a disablesleep 0 Then close the lid and the Mac keeps working. That is the good news. Now the honest part.
It needs sudo, every time
Both setting and clearing the flag prompt for your admin password. There is no way to script it away safely.
It is persistent and easy to forget
Nothing reminds you. Set it on Tuesday, forget, and your Mac never sleeps again - battery drained flat, fans working, a hot laptop sealed in a padded bag.
The built-in display can stay powered
Under a closed lid the internal panel can keep drawing power for nothing - wasted battery and extra heat exactly where it cannot escape.
All-or-nothing
It is not scoped to the build, render or agent run you actually care about. It is "this Mac never sleeps", 24/7, until you remember.
And it is not guaranteed: Apple forces sleep on lid close on some Apple Silicon models regardless of this flag. Test your own machine before you trust it with a long run - start something, close the lid for a minute, reopen and check it kept going.
Free 14-day trial · one-time $39.99 · no telemetry · macOS 13+
3. Ordinary keep-awake apps (they don't survive a lid close)
Worth saying plainly, because it saves an evening: the classic "amphetamine-style" menu-bar utilities mostly wrap the same idle-sleep assertion caffeinate uses. They are great for stopping your Mac dozing off mid-download, and they do nothing at all when the lid shuts. If a tool does not explicitly say it handles lid-closed sleep, assume it does not.
For the lid-open methods in full, see every way to keep a Mac awake, honestly.
4. The easy way: one toggle in AwakeMate
AwakeMate has a Keep awake with the lid closed option - in Settings › Options, or right in onboarding. Turn it on, approve a one-time helper, and that is the whole setup. No Terminal, no monitor, no flag to remember.
What makes it different from typing the pmset command yourself is scope: AwakeMate holds sleep off only while a tool you chose is actually running. When your build, render or agent finishes, normal sleep comes straight back.
Scoped to real work
Lid-closed keep-awake applies while a watched tool is running - Xcode, ffmpeg, Claude Code - not permanently.
It dims the screen
The built-in display is dimmed under the closed lid so it is not burning battery or adding heat, and brightness is restored when you open it.
It reverts itself
Turn the option off, or quit AwakeMate, and the setting is reverted and brightness restored. Nothing is left behind.
It never touches your energy settings
Your saved Energy Saver / Battery preferences are left exactly as you set them. The option is off by default.
The honest caveat, same as above: this works on most Apple Silicon Macs, but Apple forces sleep on some models. Close your lid once with a run going to confirm yours holds. If it does not, clamshell mode is the guaranteed fallback.
The use case it was built for: start a long agent run or build, close the lid, drop the Mac in your bag, tether it to your phone, and keep checking in from your phone on the way. That is the whole idea - see agent in your bag for the full walkthrough.
Free 14-day trial · one-time $39.99 · no telemetry · macOS 13+
Manual pmset vs AwakeMate
pmset AwakeMate sudo, every single time One toggle, one-time helper approval Running agents overnight? See why AI agents need your Mac awake.
Frequently asked
How do I keep a MacBook awake with the lid closed?
Three ways. Clamshell mode (power + external display + external keyboard or mouse) is Apple's official, guaranteed route but needs hardware. sudo pmset -a disablesleep 1 sets a system-wide sleep-disable flag that works on many Apple Silicon Macs but is persistent, needs root, and is easy to forget. Or turn on Keep awake with the lid closed in AwakeMate, which holds sleep off only while a tool you chose is actually running and reverts by itself.
Does caffeinate work with the lid closed?
No. caffeinate creates an idle-sleep power assertion, and lid-close sleep is not idle sleep - it is triggered at the hardware/firmware level the moment the lid magnet closes. The assertion is simply overridden. This is why the usual Terminal trick fails here.
Can I use clamshell mode without an external display?
Not officially. Apple's clamshell mode requires the Mac to be on power with an external display attached, plus an external keyboard or mouse to wake it. Without a display, closing the lid sleeps the Mac. Setting the sleep-disable flag (or using AwakeMate's lid-closed option) is the only way to stay awake with no monitor attached.
Is sudo pmset -a disablesleep 1 safe?
It does not damage anything, but it is risky in practice. It is system-wide and persistent, so if you forget it the Mac will never sleep - it drains the battery flat, runs hot, and can sit cooking inside a closed bag. Always check it with pmset -g | grep SleepDisabled and clear it with sudo pmset -a disablesleep 0 when you are done.
How do I check whether sleep is currently disabled?
Run pmset -g | grep SleepDisabled. A value of 1 means sleep is disabled system-wide; 0 means normal sleep behaviour. Undo it with sudo pmset -a disablesleep 0.
How do I keep my Mac working in my bag?
Turn on AwakeMate's lid-closed option, start the work you care about, tether the Mac to your phone if it needs a network, and close the lid. AwakeMate dims the built-in screen so it is not burning battery under the lid. Use a bag with airflow and keep it on power or a power bank for long runs.
Does lid-closed keep-awake work on every Mac?
No, and nobody can honestly promise that. Apple forces sleep on lid close on some Apple Silicon models regardless of the sleep-disable flag, so the same caveat applies to pmset and to AwakeMate. Test yours once: start a run, close the lid for a minute, open it and check the work continued. Clamshell mode is the only guaranteed method.