---
title: "How to keep your MacBook awake with the lid closed"
url: https://batteryorbit.app/guides/keep-mac-awake-lid-closed
markdown: https://batteryorbit.app/guides/keep-mac-awake-lid-closed.md
---

# Keep your MacBook awake with the lid closed.

Close the lid and a MacBook goes to sleep, and whatever it was doing stops: a download, a build, an AI agent. Here's what macOS lets you do, and how to keep it running with nothing plugged in but the charger.

Checked on macOS 27.2.1, 22 November 2026

On this page

1. [What macOS does when you close the lid](https://batteryorbit.app/guides/keep-mac-awake-lid-closed#what-macos-does)
2. [Keep it awake with the lid open](https://batteryorbit.app/guides/keep-mac-awake-lid-closed#lid-open)
3. [With the lid closed and no external display](https://batteryorbit.app/guides/keep-mac-awake-lid-closed#lid-closed)
4. [Do it safely](https://batteryorbit.app/guides/keep-mac-awake-lid-closed#safely)
5. [Questions](https://batteryorbit.app/guides/keep-mac-awake-lid-closed#faq)

## What macOS does when you close the lid

It sleeps, and a sleeping Mac runs nothing: downloads pause, builds stop, and an agent like Claude Code or Codex waits until you open the lid again.

There's one exception, which Apple calls **closed-display mode**: with an external display, a keyboard and a mouse or trackpad connected, and the Mac on power, you can close the lid and keep working on the big screen. A USB-C display that powers the Mac counts as the power. On Apple silicon Macs you may first need to allow the accessories to connect.

## Keep it awake with the lid open

1. Open **System Settings** › **Battery** › **Options**.
2. Turn on **Prevent automatic sleeping on power adapter when the display is off**.
3. In **Lock Screen**, set when the display turns off, on battery and on the power adapter.

That works only on the charger. In Terminal, `caffeinate -i` stops idle sleep for as long as it runs; press Control-C to end it. Apple notes that keeping a Mac awake uses more power.

## With the lid closed and no external display

![Battery Orbit's Keep awake page: 2 hours left, lid can close unlocked, display stays on, ends at 20% on battery, and the options for when you close the lid.](https://batteryorbit.app/app/keep-awake-light.jpg)
*Keep awake in Battery Orbit.*

macOS has no setting for this. `caffeinate` doesn't cover it either: its manual describes idle sleep, and its `-s` option works only on the charger, but says nothing about closing the lid.

What does work is macOS's system-wide sleep switch, `sudo pmset -a disablesleep 1`. It stops all sleep until you run it again with `0`. It never turns itself off, and a closed Mac that can't sleep keeps making heat, which is why it's risky to use by hand.

**Battery Orbit's Keep awake** uses that same switch, with limits around it. You pick how long: 30 minutes, 1, 2, 4 or 8 hours, or until you stop it. When you close the lid, the Mac stays awake and locked (or unlocked, for agents that use the screen). It switches sleep back on whenever the session ends: time up, stopped, the app quit, the battery down to your limit (10% at the latest with the lid closed), or the battery running hot. In the free trial, lid-closed sessions last up to 30 minutes.

[See Keep awake](https://batteryorbit.app/#keep-awake) · [Try it free](https://batteryorbit.app/download)

## Do it safely

- **On a desk, not in a bag.** A closed Mac that stays awake still makes heat, and a bag traps it. Apple says a MacBook works best in a room at 10–35° C (50–95° F), and advises against soft surfaces like blankets.
- **Locked unless you need it open.** Locked is the safe choice: agents in Terminal keep working. Unlocked lets agents that use the screen carry on, but anyone who opens the lid gets in.
- **On the charger for long runs.** On battery, a session that can't sleep runs the battery down. Keep awake ends at the level you pick, 20% unless you change it.
- **Know how to turn it off.** If you used Terminal, run `sudo pmset -a disablesleep 0`. In Battery Orbit, press **Stop keeping awake**, or let the session end; sleep comes back by itself.

## Questions

### Does caffeinate keep a Mac awake with the lid closed?

Not on its own. caffeinate's manual covers idle sleep, and its -s option only works on the charger; it doesn't say it stops the sleep that comes when you close the lid. The setting that does is the system-wide `pmset -a disablesleep`.

### Can I use my MacBook with the lid closed?

Yes, in Apple's closed-display mode: an external display, a keyboard and mouse or trackpad, and power. Without a display, you need a tool like Battery Orbit's Keep awake.

### Will Claude Code keep working if I close my MacBook?

Not if the Mac sleeps: everything pauses until you open it again. Keep it awake with the lid closed, and with Battery Orbit its permission requests can reach your phone while you're away.

### Is it bad to keep a closed MacBook awake?

The risk is heat. Keep it on a hard surface in a normal room, not in a bag, and on the charger for long runs. Battery Orbit's Keep awake stops by itself if the battery runs hot.

### How do I make my Mac sleep normally again?

If you used Terminal, run `sudo pmset -a disablesleep 0`. With Battery Orbit, stop Keep awake or let the session end; it puts sleep back as it was.

macOS behaviour from Apple's support pages on closed-display mode and sleep settings, and the caffeinate manual page, checked on a MacBook with macOS 27.2.1 on 22 November 2026. Battery Orbit isn't made by Apple and isn't affiliated with it. Spotted something out of date? Tell us through [Support](https://batteryorbit.app/support).
