Keep a Mac Awake With the Lid Closed for Claude Code (2026)
Keep a MacBook running with the lid closed on battery during Claude Code or Codex jobs: the pmset fix, what to check in any app, and how Glowmoth compares.
AlternativesUpdated 10 min read
On this page
You started a Claude Code or Codex run, closed the lid, put the MacBook in a bag, and came back to a stopped job. Or you found pmset disablesleep and worry you'll forget to undo it. Several small apps appeared in October and November 2026 for exactly this (Pilot Light, Lockpaw, LidAwake, Double Shot, StayAwake), and people discussing them keep asking "doesn't Amphetamine already do this?" and "doesn't agent caffeine do this for free?"
We make Glowmoth, so weigh our view accordingly; we've tried to be fair to every app here. Prices are as of November 2026.
Quick list
pmset disablesleepin Terminal: best for a one-off job if you will undo it yourself. Free, built in.- Amphetamine: best if you already use it and its closed-display mode works on your Mac. Free.
- Caffeine (iannuttall): best for free, open-source, agent-aware use. Its lid-closed mode is best-effort.
- Awakado: best if hook-based agent states ("needs you", "done") matter most. Lid-closed is in its paid Pro tier.
- Glowmoth: best if you want lid-closed mode with a battery floor, heat cut-off and 30-second fail-safe, and would use the rest of MacSuite.
Why the Mac sleeps when you close the lid
caffeinate (built into macOS) holds a power assertion that blocks idle sleep. Closing the lid isn't idle sleep: it asks the Mac to sleep, and an idle-sleep assertion doesn't stop that. Glowmoth behaves the same way in a normal session. It holds an idle-sleep assertion and never uses PreventSystemSleep, so closing the lid still sleeps the Mac unless closed-lid mode is on. For the flags, see our caffeinate command guide.
Two setups reliably keep a MacBook running with the lid shut:
- It is plugged in with an external display connected (Apple's clamshell mode). Our clamshell mode guide covers it.
- Sleep has been disabled system-wide, which is what
pmset disablesleepdoes.
If you walk away with the laptop on battery, only the second applies. That is the case every app here is built for, and it is why they differ on safety: a setting that disables sleep for the whole system has to be switched back reliably.
Keep a Mac awake with the lid closed without an app
Disable sleep (asks for your admin password):
sudo pmset -a disablesleep 1Undo it as soon as the job finishes:
sudo pmset -a disablesleep 0Check the current state and look for a SleepDisabled line:
pmset -g | grep -i sleepdisabledThis works, but you are your own watchdog. Nothing stops it at 5% battery, nothing notices the Mac running hot, and nothing restores sleep if you forget. A closed laptop in a bag has little airflow, so don't leave one running that way unattended.
What to check in any lid-closed app
People comparing the newer apps describe the same few differences.
- How does it get permission? Some install a sudoers rule that allows four
pmsetcommands without a password. Others ask for a one-time admin approval. Know which you are agreeing to. - What restores sleep if the app crashes or you quit it? Builders describe watchdogs that restore normal sleep within 30 seconds and others that take up to two minutes. Shorter is better; an immediate restore on quit is better still.
- Does it stop on low battery and on heat? These matter most when the Mac is in a bag.
- Does it let the Mac sleep when the job ends? "Awake until you remember" is the failure you're trying to avoid.
- How does it know the agent is done? Options are process detection, hooks the agent calls, or a timer. Hooks can report "needs you" directly; process detection infers activity from what the process does.
- Does it lower power use with the lid shut? One Pilot Light discussion cites 4.8 W versus 16.7 W at idle. We haven't verified that figure.
The options at a glance
| Option | Price (as of November 2026) | Lid closed on battery | Standout limit |
|---|---|---|---|
caffeinate | Built in | No | Can't hold against a lid close |
pmset disablesleep | Built in | Yes | No battery, heat or restore safety |
| Amphetamine | Free | Closed-display mode (Enhancer, Power Protect) | Last update November 2023 |
| Caffeine (iannuttall) | Free (MIT) | Best-effort | Doesn't promise every Mac works lid-shut |
| Glowmoth | Part of MacSuite, $349 one-time | Yes, via a privileged helper | Bundle only; no agent hooks |
Amphetamine
Amphetamine is free with no in-app purchases. It has 15 trigger types, AppleScript support, custom icons and sounds. For closed-display use, our notes list the separate Amphetamine Enhancer and a "Power Protect" piece in the 5.3 line. Its last update is dated November 2023.
Pick Amphetamine if you already use it, its closed-display mode works on your Mac, and you want its trigger variety. Our Amphetamine vs Glowmoth comparison goes deeper.
Caffeine (iannuttall)
This is a free, MIT-licensed menu bar app with agent awareness: it watches common coding-agent processes and can use hooks for Claude Code and Codex. It also has battery protection, a view of other processes blocking sleep, and a CLI (caffeine for 2h, caffeine status --json). It is not the original Lighthead Caffeine, which is discontinued.
Its closed-lid mode is explicitly best-effort. It does not change pmset or promise that every Mac works with the lid shut. Pick it if you want free, hook-aware and open source, and your jobs mostly run with the lid open or on power. If you need a lid-closed run on battery, test it before you rely on it.
Awakado
Awakado's agent mode works through the agents' own hooks, so it can show states like working, needs you, usage limit, stalled and done. Its battery floor and heat limit can't be turned off. Lid-closed mode sits in its paid Pro tier and uses a helper. Pick it if "needs you" signals are the main point.
Pilot Light, Lockpaw, LidAwake, Double Shot and StayAwake
These launched in October and November 2026 around this same problem. We haven't verified their permission models, watchdog timings, prices or agent support, so we won't guess or rank them. Use the checklist above. A short restore time and an explicit battery floor are good signs in any brand-new app.
Glowmoth: keeping a Mac awake with the lid closed
Glowmoth is a menu bar app that stops idle sleep. It has a closed-lid mode, an agent-aware mode and a command-line tool. Against the checklist:
- Permission. Turning on closed-lid mode installs a small privileged helper (a launchd daemon). macOS requires approval in System Settings > General > Login Items, and Glowmoth opens that pane when approval is pending. We haven't confirmed whether macOS also asks for an admin password at that step.
- How it works. While Glowmoth is keeping the Mac awake for any reason, the helper runs
pmset -a disablesleep 1. It runspmset -a disablesleep 0as soon as that ends and does nothing between sessions. No external display or power adapter is required. - Restore. The app renews a 30-second lease every 10 seconds, so normal sleep returns within 30 seconds if Glowmoth stops responding. It returns immediately if Glowmoth quits or crashes, if the helper is removed, or at shutdown. Glowmoth only undoes a
SleepDisabledsetting it set itself; if you disabled sleep withpmsetyourself, it leaves that alone. - Battery and heat. Closed-lid mode forces both limits on and disables their switches. The battery floor defaults to 20%. Closed-lid turns off below the floor ("Off below 20% battery. Plug in to resume.") and immediately when macOS reports a thermal state of serious or worse. See battery and heat limits.
- Sleeping when the job ends. Agent mode holds the Mac while an agent works and lets go after a cool-down (Allow sleep after: 2, 5 or 15 minutes; default 5). Once no reason is holding the Mac, the helper switches sleep back on. An optional end action can also sleep the Mac, lock it or turn off the display when the last reason ends on its own.
- Agent awareness. Detection is by process only, for 11 command-line agents including Claude Code and Codex. A session is "Working" if its process tree used at least 3% of a core, started or finished a child process, or wrote to its terminal; otherwise "Waiting." Desktop
.appversions such as Claude.app are not counted.
Set it up for a Claude Code or Codex run
- Right-click the moth icon in the menu bar and choose Settings… (⌘,). Open the Safety tab.
- Under Closed Lid, turn on Stay awake with the lid closed. This section appears only on Macs with a battery.
- Approve the helper in System Settings > General > Login Items (use Open Login Items if Glowmoth shows it).
- Open the Automation tab, find Coding Agents and turn on Stay awake while coding agents work. Change Allow sleep after if you don't want 5 minutes.
- Start your agent, then close the lid. Glowmoth plays the "Glass" sound and, if notifications are allowed, posts "Lid closed, staying awake."
For a single command instead of agent detection, install the CLI from Settings > Advanced > Command Line (add ~/.local/bin to your PATH if glowmoth isn't found), then run:
glowmoth run -- your-commandThis holds the Mac awake while the command runs and returns the command's exit code. See the command-line docs and closed-lid docs.
What Glowmoth does not do here
- No Low Power Mode switch and no screen cover while the lid is shut.
- No Claude Code or Codex hook integration, so no "needs you," "stalled" or "done" states and no notification when an agent waits on you.
- No wake of a sleeping Mac at a set time in normal installs.
- Laptops only; no closed-lid mode on desktops.
- Sold only as part of MacSuite ($349 one-time, as of November 2026). If keep-awake is all you need, the free options above cost less.
We also haven't confirmed what a manual Apple menu > Sleep does during a lid-closed session. Glowmoth is part of MacSuite; you can try it free for 7 days.
If the Mac still sleeps with the lid closed
| Cause | Symptom | Fix |
|---|---|---|
| Helper not approved | "Allow the Glowmoth helper in Login Items to finish." | Approve it in Login Items |
| Helper failed to install | "macOS couldn't install the helper. Move Glowmoth to Applications and try again." | Move the app to Applications, retry |
| Helper unreachable | "Can't reach the helper. Turn closed-lid mode off and on again." | Toggle closed-lid mode off and on |
| Nothing holding the Mac | Agent shows "Waiting" past the cool-down | Closed-lid works only while a reason is active |
| Manual mode on | Only your own session counts | Switch the panel to Automatic |
| Battery below floor | "Off below N% battery. Plug in to resume." | Plug in |
| Mac running hot | "Off while your Mac is running hot." | Let it cool |
| Trial ended | "Your trial has ended. Enter a MacSuite license to keep your Mac awake." | Enter a license |
If the opposite happens and the Mac never sleeps, run pmset -g | grep -i sleepdisabled. Glowmoth shows "Sleep is already turned off with pmset, outside Glowmoth." when something else disabled sleep; sudo pmset -a disablesleep 0 clears it. To see what else holds the Mac, open the panel's Show More and read "Also Keeping This Mac Awake", or see what's keeping your Mac awake.
Should you switch at all?
If your job runs on power with an external display, you need no app: that's clamshell mode. If you run one long job a month and will remember to undo it, the pmset pair is enough. If Amphetamine's closed-display mode works on your Mac, keep it.
Pick Caffeine (iannuttall) for free and hook-aware, if you accept a best-effort lid-closed mode. Pick Awakado if "needs you" states matter more than price. Pick Glowmoth for lid-closed mode with a battery floor, a heat cut-off, a 30-second fail-safe and a CLI. For a wider view, see best keep-awake apps for Mac and keeping your Mac awake while Claude Code or Codex runs.
If nothing works
For Glowmoth, write to support through our support page. Include your macOS version, the exact caption under the closed-lid switch, whether the helper is approved in Login Items, and the output of pmset -g | grep -i sleepdisabled. For another app, use that developer's support channel with the same details.
Subject: Glowmoth closed-lid mode, Mac still sleeps
macOS version:
Mac model and battery level at the time:
Caption under "Stay awake with the lid closed":
Helper approved in Login Items: yes/no
Output of: pmset -g | grep -i sleepdisabled
What was holding the Mac (panel "Held By" list):
Steps tried: toggled closed-lid mode off/on, moved app to ApplicationsCommon questions
Doesn't Amphetamine already do this?
It has a closed-display mode, and if that works on your Mac, keep it. Per our notes it pairs with the separate Enhancer and Power Protect pieces, and its last update is dated November 2023.
Is pmset disablesleep safe?
It does what it says, but nothing restores sleep unless you do. A closed laptop in a bag has little airflow, so run it only while you're watching battery and heat.
Can I run a closed-lid job on battery overnight?
Glowmoth will stop at the battery floor (20% by default), and closed-lid mode isn't yet verified on hardware. Plug in if you can.
Will Glowmoth tell me when Claude Code needs me?
No. Detection is process-based, so there are no "needs you" states or notifications. Hook-based apps such as Awakado cover that.