Adrafinil: Menu Bar Tool That Keeps Mac Awake Only When AI Agents Are Working
- Martin Chen
- Jun 28
- 3 min read
Adrafinil prevents a Mac from sleeping only when one of nine supported AI coding agents maintains an active session. The menu bar utility releases the sleep block the moment the agent finishes, so the laptop can sleep normally when the lid closes.
The tool works through the hook systems already present in Claude Code, Codex, Cursor, Gemini CLI, Aider, Hermes, OpenCode, Cline and Pi. It makes a single CLI call to each agent, confirms the session state, and returns a result in under 50 milliseconds. No agent running means the Mac follows its usual sleep schedule.
The design solves a narrow but common pain point. Developers often leave agents running overnight or through long code tasks. Standard caffeinate commands or manual energy settings either keep the machine awake too long or fail to cover the exact window the agent needs.
Adrafinil counts active sessions with a reference counter. When the last agent exits, the counter reaches zero and the sleep assertion ends. It also watches process names directly, releases the block if the Mac temperature rises above a set threshold, and drops the assertion after a configurable idle timeout.
The utility requires macOS Tahoe 26.4 or later and must be built with Xcode 26 or newer. It ships as a signed and notarized disk image. Once installed, it adds a single icon to the menu bar that shows the current agent count and allows manual override.
Users report the tool handles both short bursts and multi-hour runs without extra configuration. One developer described leaving a Cursor session for six hours; the Mac stayed awake the entire time and slept immediately after the agent finished.
The nine supported agents cover most common command-line and GUI coding workflows in 2026. No other menu bar app currently offers the same agent-specific trigger logic.
Adrafinil stays small by design. It performs only the sleep assertion and the agent checks. It does not store conversation history or attempt to monitor what the agents produce.
The same approach could support other agent types beyond coding. Any macOS process that exposes a reliable hook or process signature could be added later.
For knowledge workers who rely on agents that run extended tasks, the focused behavior matters. A general sleep blocker wastes power and keeps fans spinning after work ends. A targeted blocker ends the assertion the moment the agent reports completion.
Adrafinil ships with a simple preference pane. Users can set the temperature threshold, idle timeout, and choose which of the nine agents to monitor. Defaults cover the most common cases.
The author released the source on GitHub under a permissive license. Several contributors have already added support for two new agents since the initial commit.
Early feedback on Hacker News highlighted the low latency and the reference counting logic as the most useful parts. Several users said they had previously written custom scripts that did roughly the same job but required ongoing maintenance.
The project demonstrates a practical pattern: detect agent activity at the OS level, assert only the exact resource needed, and release it without user intervention. The pattern applies to disk spindown, external display power, and network keep-alives as well.
No pricing applies. The disk image and source are free. The only ongoing cost is the electricity saved when the Mac sleeps on schedule rather than staying awake.
The utility continues to evolve through community pull requests. Recent additions include better handling of agent subprocesses and clearer menu bar icons that reflect the current session count.
Knowledge workers using agents for research, writing, or data tasks face the same sleep issue when their agents run in the background. A narrowly scoped tool like Adrafinil shows how small, focused utilities can remove friction without adding new habits.
The release coincides with growing use of long-running agents that exceed typical idle timers. As more teams adopt such agents, expectations around power management shift from manual scripts to automatic, context-aware behavior.