The setting was never meant to cover a closed lid: OpenAI's own docs say a closed MacBook also needs an external display. To keep Codex running lid-closed without a monitor, Clamshell for Mac is a menu bar app that keeps the Mac awake with the lid closed while armed, with no sudo or admin rights; arm it before you close the lid.
An animated MacBook with a coding agent deploying a website from its terminal. The Option key is held and the lid closes: the display goes black, but the Mac stays awake, so a dimmed copy of the terminal keeps working above the closed laptop while its front edge fills with light. When the deploy is done, a pointer shows how to lift the lid. Opening it wakes the Mac to its lock screen, which unlocks to the finished run: deployed, with the live address. The lid can then be opened and closed freely.
Clamshell for Mac keeps the Mac awake with the lid closed while armed, so Codex keeps working. Free for 7 days.
Apple Silicon, macOS 14+. Notarized by Apple. 3.6 MB. Or install with Homebrew: brew install --cask clamshell.
The Codex desktop app's Keep this Mac awake setting lives in Settings, Connections and exists so the ChatGPT phone app can keep reaching your Mac. It is designed for a lid that stays open. Close the lid without a display attached and the Mac goes to sleep anyway, local Codex work stops making progress, and remote access from your phone stops until the Mac wakes. This guide shows which of three cases you hit and how to fix each one.
Why the Mac still sleeps: three cases
You closed the lid with no display attached
Expected behavior. OpenAI's remote connections docs say a Mac laptop stays available with the lid open and power connected, and that with the lid closed you should connect an external display as well. Lid-close sleep is separate from idle sleep, and the setting does not block it.
The Mac was on battery
OpenAI describes the setting as preventing sleep when the computer is plugged in and remote access is enabled. Unplugged, it does not apply, lid open or closed.
Lid open, plugged in, and it still slept
That matches openai/codex issue #23294, open as of October 2026: a Mac on power with an external monitor slept despite the setting. One commenter posted macOS logs showing Codex briefly releasing its sleep assertion right before the Mac began to sleep.
Codex disconnects on a hotspot with the lid closed
Issue #21703 reports the desktop app's separate Prevent sleep while running setting (Settings, General) failing in that setup, also open as of October 2026. Closed-lid sleep is the first thing to rule out.
Keep Codex running with the lid closed
Use an Apple Silicon MacBook on macOS 14 or later, on a ventilated desk, preferably on power. Leave Keep this Mac awake on: it still covers idle sleep while the lid is open.
- Install Clamshell and open it once. It sits in the menu bar. No sudo, admin password, kernel extension or privileged helper is involved.
- External displays can stay connected. Clamshell arms with or without one.
- Arm it. Choose arm from the menu bar menu, which covers the next close only. Or hold Option while you close the lid, on a MacBook with a lid angle sensor (the 14-inch and 16-inch MacBook Pro from 2021 on, and some newer MacBook Air models). Right-click and Shortcuts arming stay active across reopenings until you disarm.
- Confirm the armed state, then close the lid. Open the menu and look for the Armed row before the lid goes down. A paused state is not armed.
If you start Codex jobs from a script, open "clamshell://arm" requests arming and open "clamshell://disarm" ends it. The request is asynchronous, so check the menu bar before closing the lid. The Codex lid-closed guide has a full codex exec wrapper.
What happens while the lid is closed
- The Mac stays online. Codex Remote, SSH and screen sharing can keep reaching it, as long as the network itself holds up.
- Agents can still use the screen. With the Agent Screen module on (it is off by default), computer use and the iOS Simulator keep working in an armed lid-closed session while the built-in display stays black. With it off, the display sleeps instead.
- Heat is watched. At serious or critical macOS thermal pressure, Clamshell disarms toward normal lid sleep and blocks arming until the Mac cools. It does not replace airflow, so do not run it in a bag.
- Battery has a cutoff, on by default. Clamshell works on battery, and the Disarm on low battery setting (on by default) lets the Mac sleep when the battery reaches 20%.
- Opening the lid locks the Mac. The display stays dark until the lock is confirmed. If Clamshell cannot confirm it, it restores the display and asks you to lock manually.
Clamshell's core does not know about Codex; its optional Agent Status, Agent Notifications and Finish Work, Then Sleep modules show what Claude Code and Codex agents are doing, notify you, and can let them finish before the Mac sleeps. It does not answer approval prompts, or keep a flaky connection alive. Before a long run, do the two-minute timestamp check in the Codex lid-closed guide.
Clamshell keeps your Mac awake with the lid closed. Free for 7 days, then $9.99 once for one Mac. 14-day money-back guarantee.
Apple Silicon, macOS 14+. Notarized by Apple. 3.6 MB. Or install with Homebrew: brew install --cask clamshell. Also on Setapp.
Other ways to fix it
Connect an external display
OpenAI's documented setup for a closed lid. Apple's closed-display mode needs the Mac on power with an external keyboard and mouse as well. The better fit if you work at a desk with that hardware anyway.
Leave the lid open on power
Free and fully supported by OpenAI's docs: lid open, plugged in, Keep this Mac awake on. Fine at home, less so in a bag or on a shared desk.
Send the task to Codex Cloud
OpenAI says each cloud task has its own workspace and can keep working while your computer is asleep. The best fit when the job does not need your local files, tools or credentials.
Use sudo pmset -a disablesleep 1
Works with the lid closed, but it is a global admin switch with no timer, on battery too. See what pmset disablesleep does and how to undo it.
caffeinate and most keep-awake menu bar apps do not help here: they hold off idle sleep, not lid-close sleep. Why caffeinate does not work with the lid closed explains the difference.
Frequently asked questions
Why does my Mac still sleep with Codex Keep this Mac awake turned on?
The most common reason is a closed lid. OpenAI describes the setting as preventing sleep when the computer is plugged in and remote access is enabled, and its docs say a Mac laptop with the lid closed also needs an external display. On battery the setting does not apply. If the Mac sleeps with the lid open and power connected, that matches an open bug report on the openai/codex GitHub repository. To keep the Mac awake with the lid closed and no external display, Clamshell for Mac does it while armed, on power or battery, with no sudo or admin rights.
Does Codex keep running if I close my laptop?
Codex Cloud tasks do, because they run in OpenAI's cloud. Local Codex work in the desktop app or CLI stops making progress when a closed lid puts the Mac to sleep, unless an external display setup, pmset disablesleep, or a lid-sleep tool such as Clamshell for Mac keeps the Mac awake.
Can I keep Codex running with the lid closed without an external display?
Yes. Clamshell for Mac is a menu bar app that keeps an Apple Silicon MacBook awake with the lid closed and the built-in display black, without a monitor, sudo or admin rights. Arm it, confirm the armed state in the menu bar, then close the lid.
Should I turn off Keep this Mac awake if I use Clamshell?
No need. The two do not conflict. Keep this Mac awake covers idle sleep while the lid is open and the Mac is plugged in; Clamshell keeps the closed Mac awake while it is armed.
Does Clamshell detect Codex or start automatically?
Not by default. Clamshell's core does not detect running agents; its optional Agent Status, Agent Notifications and Finish Work, Then Sleep modules show what Claude Code and Codex agents are doing, notify you, and can let them finish before the Mac sleeps. You arm it from the menu bar, with Option held while closing the lid on supported models, with Shortcuts actions, or with the clamshell://arm URL.
Will Codex Remote on my phone keep working with the lid closed?
Remote needs the host Mac awake and online. With Clamshell armed the Mac stays awake and on the network with the lid closed, so Remote can keep reaching it. Clamshell does not repair a dropped network connection or answer Codex approval prompts.
Related guides
- Does Codex Goal mode keep running with the lid closed?
- Codex Locked use with the lid closed
- How to keep a MacBook awake with the lid closed
- Use Codex from your phone with the lid closed
- Keep Codex running when you close your MacBook lid
- Keep Claude Code running with the lid closed
- Run AI coding agents overnight on a MacBook
- Keep a MacBook awake with the lid closed on battery
- Clamshell mode without an external display
Sources checked October 5, 2026: OpenAI's Remote connections and Codex Cloud docs, openai/codex issues #23294 and #21703, and Apple's closed-display guidance. Clamshell behavior is described from its changelog and FAQ. Clamshell is an independent app, not affiliated with or endorsed by OpenAI. Codex is a trademark of its owner.