How to keep your Mac awake with the lid closed
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 wrap this with timers and a menu-bar switch.
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 |
Cozier hours at your Mac
Waiting on a long job? Clacky makes the time at your desk cozier: click and keyboard sounds, and a little harbour town that grows while you work. $4.99 once for 1 Mac.
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.
Before you rely on an app with the lid closed, check what it does on battery and whether it turns sleep back on when it stops.
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 you should plug in, or keep an eye on the battery and turn it off when you’re done.
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.
- Show mouse clicks on MacThe built-in option, editors, and a live ripple with a sound.
- Click sound on MacNo built-in setting: how to add one, and the permission it needs.
- Best keyboard sound apps17 free and paid apps side by side, and which one fits you.
- Keyboard sounds for focusSoft typing sounds for study, writing and coding, in your headphones.
- Keyboard sounds explainedWhat thock, creamy, clacky and poppy mean, and how each one sounds.
- Cozy Mac appsIdle games, ambient sounds, pets and soft clicks that run while you work.
- Best cursor highlighter appsSpotlights, click ripples and click sounds for demos, calls and recordings.
- Keyboard sounds not workingInput Monitoring, Secure Input, the output device and quiet settings.
- 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 cozy Mac menu-bar app with click and keyboard sounds, a screen recorder, screenshots and a little harbour town that grows while you work. See every tool · Hear the sounds in your browser
Checked on 22 October 2026. Something changed, or something here is wrong? Email hello@clacky.app.