How to keep your Mac awake with the lid closed
Updated 6 October 2026
Close a MacBook’s lid and it sleeps. That’s usually what you want, but not when a download, a render, a backup or an AI agent is still running.
There are three honest ways to keep it going: clamshell mode (Apple’s way, with an external display), a Terminal command that turns sleep off, or an app that does that for you with a safety net. Here’s what each one does, and when to use it.
The short version
- With an external display: clamshell mode is built in. Plug in power, a display and a keyboard or mouse, then close the lid.
caffeinatekeeps an open Mac awake, but it doesn’t stop lid-close sleep on its own.sudo pmset -a disablesleep 1keeps it awake with the lid closed, even on battery. Undo it withsudo pmset -a disablesleep 0.- Never put a running, closed MacBook in a bag: it can’t cool itself, and it can drain the battery.
- Apps like Amphetamine and Clacky’s Keep Awake wrap this with timers and a low-battery stop.
Which way fits you
| Lid open | Lid closed + display | Lid closed, no display | |
|---|---|---|---|
| caffeinate | Yes | No | No |
| Clamshell mode | Yes | On power | No |
| pmset disablesleep | Yes | Yes | Yes |
Keep Awake, with a safety net
Clacky’s Keep Awake stays on for as long as you choose, or until your AI agent finishes. Lid-closed mode stops at low battery and turns sleep back on when it stops. Free for 7 days, no card.
Clamshell mode (Apple’s way)
If you use your MacBook with an external display, this is the built-in, supported way. Apple’s requirements:
- Connect the power adapter.
- Connect an external display, and an external keyboard and mouse or trackpad.
- Close the lid once the Mac is awake and showing on the display.
The Mac keeps running on the external display. On newer macOS versions you may have to allow a new accessory to connect before it works with the lid closed.
Sources: Apple: use an external display with your Mac laptop · Apple: allow accessories to connect
Also worth knowing: System Settings → Battery → Options has Prevent automatic sleeping on power adapter when the display is off. It stops the Mac sleeping when the screen turns off on its own. It doesn’t stop lid-close sleep. Apple: sleep and wake settings
caffeinate (built in, lid open)
caffeinate is a Terminal command that ships with macOS. It holds the Mac awake while it runs:
caffeinate -dis # keep the display and the system awake until you press Ctrl-C
caffeinate -i -t 3600 # stay awake for one hour
caffeinate -i -w 12345 # stay awake until process 12345 ends-d keeps the display on, -i stops idle sleep, -s stops system sleep (only on power), -t sets a time limit in seconds and -w waits for a process. It’s great with the lid open. Closing the lid is a different kind of sleep, and caffeinate alone doesn’t stop it, especially on battery.
Source: man caffeinate (online copy)
pmset disablesleep (lid closed, no display)
This one really does keep a MacBook running with the lid shut, with or without power:
sudo pmset -a disablesleep 1 # never sleep, even with the lid closed
sudo pmset -a disablesleep 0 # back to normalIt asks for your password because it changes a system power setting, and it stays on until you turn it back off, even after a restart. That’s the risk: forget it, close the lid, put the Mac in a bag, and it keeps running with no airflow, getting hot and draining the battery.
So if you use it:
- Set a reminder to run the
0version. - Keep the Mac on a hard surface, open to the air, ideally on power.
- Check with
pmset -g:SleepDisabled 1means it’s still on.
Source: man pmset (online copy)
Apps: the same, with a safety net
Apps wrap these switches with timers, a menu-bar switch and limits.
- Amphetamine is free on the Mac App Store and can be set to allow staying awake when the display is closed.
- Clacky’s Keep Awake keeps the Mac and its screen awake for 15 minutes, 1 hour, 2 hours, until you turn it off, or until your AI agent is done. Its optional Lid-closed mode uses the same
pmset disablesleepswitch as above, with rails around it: - macOS asks for your password each time you turn it on or off; there’s no hidden helper.
- On battery, it stops by itself at 20% (or 10% or 30%, or never).
- If Clacky ever quits with sleep still off, it turns sleep back on at the next launch, and Let My Mac Sleep Again… is always in the menu.
- It’s off until you allow it in Settings, next to a “Never in a bag” warning.
Whatever you use: a closed MacBook that’s awake is still running. Give it air.
Questions
Does caffeinate keep my Mac awake with the lid closed?
Not reliably. caffeinate stops idle sleep, and -s stops system sleep on power, but closing the lid is handled separately. Use clamshell mode (with a display) or pmset disablesleep.
Is it bad to run a MacBook with the lid closed?
Running it on a desk with an external display is normal (that’s clamshell mode). The risk is a closed, awake Mac with no airflow, like in a bag or under a pillow: it can get hot and drain the battery.
How do I undo pmset disablesleep?
Run sudo pmset -a disablesleep 0. Check with pmset -g: if SleepDisabled shows 0, sleep is back to normal.
Will my Mac stay awake on battery with the lid closed?
Clamshell mode needs power. pmset disablesleep works on battery too, which is exactly why a battery limit (like Clacky’s 20% stop) is a good idea.
More guides
- Claude Code & Codex notificationsA sound or a notification when your agent is done or needs you.
- Keyboard & click sounds on MacHow they work, the permission they need, the apps, and fixes.
- Teleprompter on MacRead your script under the camera, and keep it out of the recording.
- Show clicks and record click soundsGet the click ripple and the click sound into any Mac screen recording.
- Typing test with keyboard soundsA 30-second typing test you can hear, right in your browser.
New to Clacky? It’s a small Mac menu-bar app with sounds, a recorder, screenshots, Mac health and agent alerts in one dashboard. See every tool · Try it free for 7 days
Checked on 6 October 2026. Something changed, or something here is wrong? Email hello@clacky.app.