Guide · October 2026

What Codex's ‘Keep this Mac awake’ doesn't cover

The ‘Keep this Mac awake’ switch in the Codex app's Settings › Connections only prevents sleep while the Mac is plugged in and remote access is on. On battery, or with the lid closed and no external display, the Mac still sleeps and the task you started from your phone stops.

What the switch does

When you connect this Mac for phone control under Settings › Connections in the Codex app (the ChatGPT desktop app), the same screen has Keep this Mac awake. The official description: “Prevent sleep when computer is plugged in and remote access is enabled.” It only blocks sleep when both are true: on power and remote access on.

The docs say a Mac laptop stays reachable “with the lid open and power connected”, and that with the lid closed you should connect an external display as well. Choosing Sleep from the menu still ends remote access. If the computer sleeps, loses network access or closes the app, remote access stops until it's back.

Locked use (Settings › Computer Use) is a different thing: it briefly unlocks a locked screen so Computer Use can work in apps. It doesn't prevent sleep.

Checked 2026-10-27 against OpenAI's ‘Remote connections’ and ‘Computer Use’ docs (learn.chatgpt.com). Things change; check the app's settings.

When it still stops

On battery (café, commute): unplug and the condition breaks, so normal idle sleep returns. Lid closed (bag, bedside): without an external display, macOS sleeps immediately. After the work is done: as long as remote access stays on, a plugged-in Mac stays awake. What you want is ‘only while it's working’; this switch means ‘the whole time it's connected’.

Do it yourself

To stay awake with the lid closed you need sudo pmset -a disablesleep 1, and you must set it back with sudo pmset -a disablesleep 0: it survives restarts, and if you forget, the Mac stays awake in your bag, draining and heating. For Codex CLI, caffeinate -i codex exec "…" blocks idle sleep for a single run (Codex CLI guide).

With Lidnight

Lidnight watches the Codex app's work process and Codex CLI hooks, keeps the Mac awake only while Codex works (lid closed, on battery too), and restores the setting and lets the Mac sleep 10 minutes after everything goes quiet. It undoes a leftover setting at boot and stops at a battery floor or high temperature. Keep using the Codex app's remote access as is; Lidnight only covers what it leaves out: battery, lid closed, and sleeping when done.

When Codex asks to run a command or edit files while you're away, you can answer from your phone or a Mac notification (Codex's PermissionRequest hook; trust it in /hooks), and when you open the lid a recap shows what finished and what's waiting for you. Lid-closed is a Pro feature, included in the free trial (5 runs or 14 days). Keep a MacBook awake with the lid closed

Try Lidnight free

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

Homebrew: brew install whereisdw/tap/lidnight