Close Your MacBook Lid Without Killing Your AI Agents (Open-Source macOS Keep-Awake)
说明与用途
Awake 让 MacBook 在关闭机盖时保持运行,立即锁屏,并在电池温度达到 40 °C 或电量降至 10 % 时自动恢复睡眠。
问题
Closing a MacBook lid on battery or unplugged causes macOS to enter clamshell sleep, dropping SSH sessions, freezing Docker builds, and killing background AI coding agents.
结果
Awake enables continuous operation with the lid closed, protects against overheating and low battery, and maintains security by locking the screen.
工作流
- 1. Install Awake via script or Homebrew.
- 2. Run
awake 2hto keep the Mac awake for 2 hours, orawake -- bun run buildto keep awake until a command finishes. - 3. Awake toggles
pmset -a disablesleep 1andcaffeinate -dimswhile monitoringAppleClamshellState. - 4. On lid close, Awake locks the screen immediately.
- 5. Awake polls
AppleSmartBatteryevery 30s; if temperature ≥40°C or charge ≤10%, it trips a breaker, allows sleep, and auto-resumes when conditions normalize.
证据
Every time you close your MacBook lid on battery or unplug your display to walk to a meeting, macOS enters clamshell sleep. Your SSH sessions drop, your Docker builds freeze, and your background AI coding agents die mid-run.
So I built and open-sourced Awake — a tiny native macOS 26 Control Center widget, Menu Bar timer, and CLI that keeps your MacBook running with the lid closed, locks the screen the instant the lid shuts, and automatically re-enables sleep if the battery temp hits 40°C or drops to 10%.
- 记录日期: 2026-11-03T18:13:48.554Z