agentawake is a root LaunchDaemon for macOS laptops. It keeps the machine awake while Claude Code, Codex, or Oh My Pi (OMP) are actively running turns, even when the lid is closed on battery power.
Apple provides one public assertion that can prevent sleep when the lid closes: caffeinate -s, which creates a PreventSystemSleep assertion. Apple documents that this assertion only works on AC power. On battery power, macOS ignores it and puts the machine to sleep when the lid closes.
agentawake works around this by toggling the undocumented root power setting:
pmset -a disablesleep 1When active turns finish, agentawake turns sleep back on.
- Undocumented private setting:
pmset -a disablesleepis not a public or supported Apple API. It can break or disappear in a future macOS release. - Battery drain and heat: With the lid closed on battery, the Mac stays fully awake, drains the battery, and gets warm.
- macOS only: This project depends on
pmset,launchd, and macOS power assertions.
agentawake checks for active work every 30 seconds and reacts immediately when the power source changes:
- Claude Code: Detects the active
caffeinatechild created while a turn runs. - Codex: Detects the
Codex is running an active turnpower assertion. - Oh My Pi (OMP): Detects the
Oh My Pi agent sessionpower assertion.
Idle agent windows do not keep the machine awake.
- 10-minute cooldown: Sleep stays disabled for 10 minutes after the last active turn, then returns to normal.
- Below 20% cutoff: On battery, sleep is restored when the charge falls below 20%, even if an agent is still working.
- 25% resume threshold: After the cutoff trips, agent work can disable sleep again once the battery reaches 25%. The gap prevents repeated switching around one battery percentage.
agentawake can use Pager for native desktop panels.
When Pager is installed, panels report:
- unplugging the Mac while an agent is working;
- the low-battery cutoff;
- a failure to change the sleep setting.
Pager is detected at the logged-in user's ~/.local/bin/pager, /opt/homebrew/bin/pager, or /usr/local/bin/pager. The daemon starts Pager as the logged-in user through launchctl asuser. Pager never runs as root.
Pager is optional. Without it, every sleep-control feature still works and state changes are written to /var/log/agentawake.log.
The installer first proves that pmset disablesleep works on the machine, then restores the previous setting. It also refuses to place a root daemon under a directory that another user can modify.
git clone https://github.com/SignedAdam/agentawake.git
cd agentawake
sudo ./install.shTo update, pull the repository and run sudo ./install.sh again.
Installed files:
- executables:
/usr/local/libexec/agentawakeand/usr/local/libexec/agentawake-pslog; - LaunchDaemons:
/Library/LaunchDaemons/com.albastov.agentawake.plistand/Library/LaunchDaemons/com.albastov.agentawake-pslog.plist; - log:
/var/log/agentawake.log.
Run the behavioral tests. They make no changes to system sleep:
make testTest the private pmset flag and the optional Pager bridge:
sudo ./probe.shprobe.sh restores the previous sleep setting even when interrupted.
Watch state changes:
tail -f /var/log/agentawake.logInspect the current setting:
pmset -g | grep SleepDisabledSleepDisabled 1 means the block is active. SleepDisabled 0, or no line, means normal sleep is allowed.
sudo ./uninstall.shThis unloads both LaunchDaemons, removes the installed executables, clears runtime state, and sets disablesleep back to 0.
MIT, copyright 2026 Adam Albastov.