Close the lid. Keep running.
Lid-closed keep-awake for macOS — with a native Control Center toggle, Menu Bar timer, CLI, instant screen lock on lid close, and a backpack thermal & battery circuit breaker.
Website · Download DMG · Install · How it works · Security
When you kick off a long coding agent session (claude, codex, cursor, opencode), an SSH tunnel, or a large upload and close your MacBook lid on battery:
-
Bare
caffeinateonly blocks idle sleep. Closing the lid triggers Clamshell Sleep, drops Wi-Fi within seconds, and kills every in-flight CLI and network call. -
caffeinate -imswithout-dletspowerdenter low-power display-sleep mode, which causesWiFiAgentto drop weak hotel or tether connections. -
Raw
sudo pmset -a disablesleep 1is dangerous on its own:- Because
SleepDisabled = 1andcaffeinate -dsuppressSystemWillSleepandkCGSDisplayWillSleep, closing the lid leavesloginwindowunlocked (IOConsoleLocked = No). - If you toss your MacBook into a backpack and forget to run
pmset -a disablesleep 0, it will cook itself past$45^\circ\text{C}$ or drain the battery to$0%$ .
- Because
Awake fixes all four:
-
True lid-closed keep-awake: Combines
pmset -a disablesleep 1,caffeinate -dims(keepingpowerdin unrestricted Wi-Fi performance mode), and IOKitkPMSetClamshellSleepState. -
Instant screen lock on lid close: Observes
IOPMrootDomain(AppleClamshellStateNo → Yes) and callsSACLockScreenImmediate()in-process so your Mac locks the instant the lid closes — without sleeping the display or dropping Wi-Fi. -
Backpack thermal & battery guard with auto-resume: Checks battery
%,AppleSmartBatterytemperature ($^\circ\text{C}$ ), and macOS thermal pressure every 30 seconds. If battery drops to$\le 10%$ on battery power, or a closed lid reaches$\ge 40^\circ\text{C}$ or thermal pressure$\ge 1$ , Awake automatically pauses and restores normal sleep — then resumes automatically once plugged in or cooled down ($+4%$ battery /$-2^\circ\text{C}$ hysteresis). -
Zero-drift UI (
Awake.app): Native macOS 26 Control Center widget (ControlWidgetToggle) + Menu Bar timer backed by in-process IORegistry reads,sysctlPID checks, and akqueuewatcher on~/.cache/awake.
Builds Awake.app locally with your Xcode certificate (for the macOS 26 Control Center widget) or downloads the prebuilt release bundle, links ~/.local/bin/awake and ~/.local/bin/asleep, and installs /etc/sudoers.d/awake:
curl -fsSL https://il.ly/awake/install.sh | shPaste into Claude Code, Cursor, Codex, or OpenCode:
Install https://github.com/Illyism/awake on my Mac
brew tap illyism/awake https://github.com/Illyism/awake
brew install --cask illyism/awake/awake
awake setup(Or brew install --formula illyism/awake/awake for the CLI formula only.)
Download Awake-1.0.2-macos-arm64.dmg (Developer ID signed and notarized by Apple), drag Awake.app to Applications and launch it. The Awake window walks you through setup: the lid-closed sleep guard (Touch ID), the Control Center toggle and the command line tool.
Can't see the cup icon in the menu bar? On MacBooks with a notch, a full menu bar hides icons behind the camera. Hold ⌘ and drag other icons out to make room, open Awake again from Applications, or use the Control Center toggle.
nix profile install github:Illyism/awakeOr in nix-darwin:
services.awake.enable = true;-
Menu Bar: Click the cup icon (
cup.and.heat.waves.fill) in the menu bar to toggle Keep Awake Indefinitely or start a 30m / 1h / 2h / 4h countdown, view live battery%and temperature ($^\circ\text{C}$ ), or hide the menu bar icon if you only use Control Center. - Control Center (macOS 26+): Open Control Center → Edit Controls… → search "Awake" and drag the toggle into Control Center.
awake # Keep awake indefinitely (lid can close, Wi-Fi stays up)
awake 45m # Keep awake for 45 minutes (s / m / h, or minutes)
awake -- codex exec … # Keep awake while a command runs, then restore sleep
awake status # Show caffeinate PID, timer, lid state, temp °C, and battery
asleep # Restore normal sleep immediately (alias for `awake stop`)
awake setup # Install /etc/sudoers.d/awake (validated via visudo -cf)$ awake status
awake caffeinate pid 22253 (42m left)
lid sleep disabled
temp 30C (lid limit 40C)
last auto-stop: battery at 10%, Mon 21:08
power Now drawing from 'AC Power'
power -InternalBattery-0 (id=23003235) 87%; charging; 0:51 remaining present: true
| Variable | Default | Description |
|---|---|---|
AWAKE_MIN_BATTERY |
10 |
Pause when on battery at or below this % (resumes on AC or at |
AWAKE_MIN_BATTERY_LID |
10 |
Pause when lid is closed on battery at or below this %
|
AWAKE_MAX_BATT_TEMP_LID |
40 |
Pause when lid is closed and battery reaches this temperature ( |
AWAKE_MAX_THERMAL_LID |
1 |
Pause when lid is closed and macOS thermal pressure reaches this level (0 nominal, 1 moderate) |
If you create an executable script owned by your user at ~/.config/awake/on-sleep (chmod 700), Awake runs it automatically:
on-sleep idle— whenasleepruns or when the lid closes whileawakeis activeon-sleep sleep— when the Mac enters normal sleep or pauses on a battery/thermal safety threshold (useful for auto-unmounting encrypted volumes or locking vaults when closing the lid)
-
Zero network requests or telemetry: Neither
awake,Awake.app, norAwakeControl.appexmakes any network calls. -
Minimal, exact-match
sudoersrule:/etc/sudoers.d/awakeis validated with/usr/sbin/visudo -cfbefore installation and permits only two exact commands with no wildcards or flags:%admin ALL=(root) NOPASSWD: /usr/bin/pmset -a disablesleep 0, /usr/bin/pmset -a disablesleep 1 -
Sandboxed WidgetKit extension:
AwakeControl.appexruns inside the macOS App Sandbox (com.apple.security.app-sandbox = true) with a single read-only exception for~/.cache/awake/(0700user-owned directory). -
Hardware SMC safety intact: Kernel SMC emergency thermal protection remains active at all times, with Awake's user-space watcher pausing keep-awake long before hardware limits (
$40^\circ\text{C}$ battery / moderate thermal pressure).
curl -fsSL https://il.ly/awake/install.sh | sh -s -- uninstall