For agents · Cursor

Keep your Mac awake
while Cursor works.

Cursor's agent works inside the editor on your Mac, so it stops when the Mac sleeps. Midnight Oil can stay awake whenever Cursor is open, or just for one long agent run, even with the lid closed.

The short answer

Easiest: add an App Running trigger for Cursor in Midnight Oil's settings, and the Mac stays awake whenever Cursor is open. For a single run, tell the agent “keep my Mac awake until you're done,” or use the CLI: midnightoil run -- agent -p "…".

Cursor at a glance

Runs whereIn the Cursor editor, or the Cursor CLI in your terminal
InteractiveThe Agent panel in the editor, or agent in a terminal
Unattendedagent -p "…" (print mode) runs one prompt and exits
Instructions file.cursor/rules/; the CLI also reads AGENTS.md and CLAUDE.md
Needs your Mac awake?Yes for the editor and CLI. Cursor's background agents run in the cloud and don't.

What happens when your Mac sleeps mid-run

Cursor's agent lives in the editor, and the editor sleeps with the Mac. The agent's model request is cut off, the terminal command it started freezes, and the chat sits at the step it was on until you wake the Mac.

An open editor doesn't hold the Mac awake. macOS goes to sleep on its idle timer, and always when the lid closes.

Just ask Cursor

With Midnight Oil installed, Cursor can run the midnightoil command for you. Say it in your own words:

You sayCursor runs
“Keep my Mac awake while you finish this refactor.”midnightoil start
“Run the e2e tests and keep the Mac awake until they're done.”midnightoil run -- npx playwright test
“Keep it awake for two hours, screen off.”midnightoil start --for 2h --allow-display-sleep

The session shows up in the menu bar like one you started yourself, so you can see it, extend it, or end it with a click.

Make it automatic

Add this line to AGENTS.md or a Cursor rule and Cursor keeps the Mac awake for every long command without being asked:

For AGENTS.md or a Cursor ruleCursor reads midnightoil --help for the rest.
For commands that take more than a few minutes, run them through `midnightoil run -- <command>` so the Mac stays awake until they finish.

Running Cursor unattended

In the editor: open Midnight Oil's Settings › Triggers › Add Trigger › App Running › Cursor. The Mac stays awake whenever Cursor is open and sleeps normally once you quit it. Turn on “Stay awake with the lid closed” in the trigger to cover a closed laptop.

From the CLI: agent -p runs one prompt and exits (add --force to let it change files without asking). Wrap it in midnightoil run and the session ends with the run.

Keep the Mac awake for the whole session

midnightoil run -- agent

Or for one unattended run

midnightoil run --lid-closed -- agent -p --force "upgrade the project to React 19"

Lid closed, battery safe

Add --lid-closed and Cursor keeps working with the laptop shut. It needs a one-time approval in Midnight Oil's Settings › Closed Lid, and normal sleep comes back the moment the session ends, even if the app quits or crashes.

On battery, sessions can end when you unplug or drop below a level you pick, and an alarm sounds if the lid closes during a closed-lid session. Add --allow-display-sleep to let the screen go dark while the Mac keeps working. The full setup is in how to run AI agents overnight.

Questions

Does Cursor's agent keep running when my Mac sleeps?

No. The editor and the agent pause with the Mac. Cursor's background agents run in the cloud and are unaffected; everything in the editor and the Cursor CLI needs the Mac awake.

How do I keep my Mac awake whenever Cursor is open?

Add an App Running trigger for Cursor in Midnight Oil's Settings › Triggers. The Mac stays awake while Cursor runs and sleeps normally after you quit it.

Where does the instruction go?

In a rule under .cursor/rules, or in AGENTS.md at the project root, which Cursor's CLI also reads. The line: For commands that take more than a few minutes, run them through `midnightoil run -- <command>` so the Mac stays awake until they finish.

Let Cursor work the night shift.

Free. No account, no subscription.

macOS 14 or later · Apple Silicon and Intel · brew install --cask coreyhaines31/tap/midnightoil