Keep your Mac awake with the lid closed.
Close your MacBook on battery without dropping Claude Code, Codex, Cursor, or SSH. Locks the screen on close and pauses automatically at 10% battery or 40°C.
curl -fsSL https://il.ly/awake/install.sh | shSigned & notarized for Apple silicon · Control Center, Menu Bar, and CLI
Why bare caffeinate drops your agents
macOS separates idle sleep from clamshell sleep. Closing the lid on battery overrides caffeinate within seconds, while raw pmset leaves your screen unlocked and lets a closed laptop overheat in a backpack.
caffeinate / Amphetamine
- Lid closed
- Sleeps immediately, drops Wi-Fi
- Screen lock
- Via normal sleep
- Safety guard
- Already asleep
Raw pmset disablesleep 1
- Lid closed
- Stays awake
- Screen lock
- Left unlocked on close
- Safety guard
- Overheats in bag or drains to 0%
Awake
- Lid closed
- Stays awake, Wi-Fi stays up
- Screen lock
- Locks screen immediately
- Safety guard
- Pauses at 10% battery or 40°C, resumes when calm
Unrestricted Wi-Fi on battery
Holds full display and system assertions alongside lid-sleep disable, so macOS does not drop weak hotel or cafe Wi-Fi when the lid shuts.
Instant screen lock on close
Disabling clamshell sleep suppresses the normal macOS sleep lock. Awake watches the lid sensor and locks your login screen immediately.
Backpack heat & battery guard
Checks battery level and internal temperature every 30 seconds. Pauses at 10% battery or 40°C in a bag, then auto-resumes once cooled or plugged in.
Native toggle that never drifts
Control Center toggle, Menu Bar countdown timer, and CLI stay synced directly with kernel sleep state so a reboot never leaves the switch wrong.
Two words in your terminal
Use the Control Center toggle, set a timer from the menu bar, or wrap any long command directly in zsh.
~/.local/bin/awake$ awake setup # one-time sudoers rule (or Touch ID in menu bar)
$ awake # keep awake indefinitely with lid closed
$ awake 45m # countdown timer (s / m / h), then restore sleep
$ awake -- claude -p "..." # stay awake only while a command runs
$ awake status # live PID, timer, battery %, and chassis temp
$ asleep # restore normal sleep immediatelyAuditable in five minutes
macOS requires root to change clamshell sleep. Awake validates and installs a single sudoers file at /etc/sudoers.d/awake that allows only two exact commands with no wildcards:
%admin ALL=(root) NOPASSWD: /usr/bin/pmset -a disablesleep 0, /usr/bin/pmset -a disablesleep 1- Zero network callsNeither the CLI, the menu bar app, nor the Control Center widget ever opens a network socket.
- Sandboxed extensionThe Control Center extension runs in the macOS App Sandbox with read-only access to local state.
- Optional sleep hookAdd an executable script at ~/.config/awake/on-sleep to auto-unmount encrypted drives when closing the lid.