为什么值得关注
它精确解决了开发者在合盖状态下持续运行 Codex 任务的需求,仅依赖 macOS 原生机制,无需安装任何第三方后台服务。
适合谁使用
- 在 MacBook 上运行 Codex AI 任务的开发者
- 需要合盖保持网络连接(如手机热点)的远程工作者
- 需要长时间下载、同步或批处理任务的 MacBook 用户
典型使用场景
- 合盖携带 MacBook 时,让 Codex 任务持续运行不中断
- 通过手机热点保持网络连接,完成大文件传输或同步
- 在夜间合盖运行不需要中断的自动化脚本或训练任务
项目优势
- 无需第三方后台服务,仅使用 pmset 和 LaunchDaemon 等内置机制
- 提供 1、2、4、8 小时定时开关,到期自动恢复睡眠
- 开机时自动复位 disablesleep 设置,避免意外重启后系统异常
- 轻量级 AppleScript 应用,配合脚本快速安装使用
使用前须知
- 使用未文档化的 pmset disablesleep 设置,macOS 大版本升级后可能需要重新验证
- 使用过程中需要管理员权限(root)授权
- 使用时必须注意通风散热,严禁放入包中或密闭空间以免过热
README 快速开始
Codex Lid Awake for macOS
Keep a MacBook awake and online while its lid is closed, so long-running Codex tasks can continue.
[!WARNING] This intentionally prevents system sleep. Keep the MacBook ventilated, preferably connected to power, and never put it in a bag while active.
简体中文
功能
Codex Lid Awake 是一个轻量的 macOS AppleScript 应用。开启后,即使合上 MacBook 盖子,系统也不会进入睡眠,因此手机热点、网络连接和正在运行的 Codex 任务可以继续工作。
- 可选择保持 1、2、4 或 8 小时;
- 到期后自动恢复正常睡眠;
- 再次打开应用可提前恢复;
- 附带开机复位保护,意外重启后恢复默认合盖睡眠;
- 不安装第三方后台服务。
构建与安装
打开“终端”,依次执行:
git clone https://github.com/FrankJing420/codex-lid-awake.git
cd codex-lid-awake
./scripts/build-app.sh
./scripts/install.sh
安装完成后,在“应用程序”中打开 Codex Lid Awake,选择时长并完成管理员授权。需要提前结束时,再次打开应用并选择“恢复正常睡眠”。
工作原理
应用使用 macOS 的 pmset disablesleep 设置临时阻止系统睡眠,并使用根权限计时器按时恢复。附带的 LaunchDaemon 会在每次开机时将该设置复位为 0。
disablesleep 是未公开文档化的系统设置,请在 macOS 大版本升级后重新验证。
紧急恢复
若应用无法打开,可在终端执行:
sudo pmset -a disablesleep 0
卸载
sudo rm -rf "/Applications/Codex Lid Awake.app"
sudo launchctl bootout system/local.codex.lidawake-reset
sudo rm -f /Library/LaunchDaemons/local.codex.lidawake-reset.plist
English
Features
Codex Lid Awake is a lightweight macOS AppleScript app. While enabled, closing the MacBook lid does not put the system to sleep, allowing a phone hotspot, network connection, and long-running Codex tasks to continue.
- Timed sessions of 1, 2, 4, or 8 hours;
- Automatic restoration when the timer expires;
- Early restoration by opening the app again;
- A boot-time safety guard that restores normal lid sleep after an unexpected restart;
- No third-party background service.
Build and install
git clone https://github.com/FrankJing420/codex-lid-awake.git
cd codex-lid-awake
./scripts/build-app.sh
./scripts/install.sh
Open Codex Lid Awake from Applications, select a duration, and authenticate. Open it again to restore normal sleep early.
How it works
The app temporarily enables the undocumented macOS pmset disablesleep setting. A privileged timer restores the original behavior when the session expires, and the included LaunchDaemon resets the setting to 0 at every boot.
Emergency recovery
sudo pmset -a disablesleep 0