Guide · October 2026

How to keep a MacBook awake with the lid closed

No external display, even on battery. Why the built-in options don't work, and how to do it safely.

Why closing the lid puts the Mac to sleep

macOS sleeps the Mac when you close the lid. The only exception is clamshell mode, which needs a power adapter, an external display and an external keyboard or mouse all connected. That rules out cafés and commutes.

caffeinate, keep-awake apps and the “Prevent automatic sleeping when the display is off” setting stop idle sleep. Lid-close sleep is a separate mechanism, so in most setups the Mac still sleeps when you close it.

Doing it yourself in Terminal

The command that also disables lid-close sleep is sudo pmset -a disablesleep 1. Turn sleep back on with sudo pmset -a disablesleep 0.

The catch: it's easy to forget to undo. If the Mac stays awake in your bag after the work is done, the battery drains and it heats up. The setting even survives a restart.

Automatically with Lidnight

Lidnight uses the same mechanism but remembers to turn it on and off for you. While AI work is running (Claude Code, Codex, Gemini CLI, Ollama and 41 more), the Mac stays awake with the lid closed, then sleeps normally when the work is done. A timer mode is there too (up to an hour, no limit in Pro).

Safety nets: it sleeps right away if the battery drops below your floor or it gets hot, like in a bag. If the app quits or the Mac restarts, sleep settings go back to normal.

You can also choose whether closing the lid locks and turns off the screen, and whether opening it shows your work right away.

Questions

Is it safe on battery with the lid closed? Yes, as long as heat can escape. A MacBook vents from the bottom and back even when closed. In a closed space like a bag, Lidnight watches the temperature and puts it to sleep.

Does it work on Intel Macs? Lidnight is for Apple Silicon Macs (M1 and later).

Try Lidnight free

Apple Silicon Macs · macOS 13 or later. Every download includes a 7-day trial of everything in Pro, no payment details needed. Pro is a one-time payment (1 Mac $4.99 · 3 Macs $9.99) with a 14-day refund.

Homebrew: brew install --cask whereisdw/tap/lidnight