Adrafinil: the lid-closed Mac problem finally has a real fix

4 min read 1 source clear_take
├── "Process-aware wake assertions are the right solution — they fix the actual failure mode of existing tools"
│  ├── kageroumado (Hacker News, 103 pts) → read

The Adrafinil author frames the tool as a direct response to the half-open-MacBook phenomenon, arguing that engineers reject Amphetamine because forgetting to disable it leads to a discharged laptop in the bag. By tying the wake assertion to active agent processes, the tool eliminates the human-error mode while still letting Claude Code, Cursor, and Codex sessions run with the lid closed.

│  └── top10.dev editorial (top10.dev) → read below

The editorial argues that Adrafinil correctly identifies a gap that neither tmux nor Amphetamine fills: local agent processes need CPU, network, and filesystem access on the actual laptop, and unconditional caffeination has a well-known failure mode of cooked aluminum in a backpack. Process-scoped assertions are the principled fix because they auto-release when the work is done.

├── "Just use tmux — this is a solved problem"
│  └── @HN commenters (snark contingent) (Hacker News) → view

A subset of the HN thread dismisses the tool by pointing to tmux as the canonical answer for keeping long-running sessions alive. The editorial notes this position misunderstands the problem — tmux handles SSH session persistence, not local IDE-integrated agent processes that need to keep the host machine itself awake.

└── "Amphetamine/caffeinate is good enough — you just have to remember to turn it off"
  └── @HN commenters (Amphetamine defenders) (Hacker News) → view

Some commenters defend existing unconditional wake tools, arguing that occasional use doesn't justify a new utility. The author's own framing concedes these users exist but counters that 'forgetting to disable Amphetamine and finding my laptop discharged in my bag is worse' — the very failure mode that motivated Adrafinil.

What happened

A GitHub project called Adrafinil (github.com/kageroumado/adrafinil) hit Hacker News this week at 103 points, solving a problem that has quietly become one of the most-photographed status symbols of 2026: the half-open MacBook in the wild.

If you've been on developer Twitter at all this spring, you've seen the photos. Engineers in Blue Bottle, in Dolores Park, on the BART — laptops cracked open exactly 30 degrees, screen dark but lid defiantly ajar. The reason is unglamorous: macOS aggressively suspends processes when the lid closes, which means your Claude Code agent grinding through a refactor, your Cursor background task, or your long-running Codex session all stop the moment you pack up to leave the café. So engineers stopped closing the lid.

Adrafinil — named, with appropriate dryness, after a wakefulness-promoting nootropic — is a small Mac utility that watches for agent processes and asserts a `kIOPMAssertionTypePreventUserIdleSystemSleep` only while one is active. When the agent finishes, the assertion drops, and the Mac sleeps normally. No menu bar toggle to forget. No background daemon burning battery in your bag.

Why it matters

The obvious snark — and the HN thread is full of it — is *"just use tmux"* or *"just use Amphetamine."* Both are wrong in instructive ways.

`tmux` solves session persistence over SSH. It does not solve a local agent process that needs CPU, network, and a writable filesystem on your actual laptop. Claude Code and Cursor agents aren't shells; they're full IDE-integrated processes making API calls, running test suites, writing files. You can't tmux your way around macOS power management.

Amphetamine and `caffeinate` solve the opposite half of the problem: they keep the machine awake unconditionally. The failure mode is the one every Amphetamine user has hit at least once — laptop in the backpack, fan spinning quietly all the way home, 4% battery and a warm aluminum brick at the destination. The top reply on the HN thread captures it perfectly: *"forgetting to disable Amphetamine and finding my laptop discharged in my bag is worse"* than the half-open-lid workaround.

Adrafinil's insight is that the right primitive isn't "keep awake" or "sleep normally" — it's conditional wakefulness gated on a specific workload. This is genuinely new territory for end-user Mac tooling. The closest prior art is Apple's own Power Nap, which wakes the machine periodically for Time Machine and Mail — but Power Nap is opaque, Apple-controlled, and doesn't expose hooks for third-party processes.

The deeper signal here is what the half-open-lid epidemic reveals about how agentic workflows have outgrown the assumptions of consumer operating systems. macOS was designed around the assumption that closing the lid means "I'm done" — but in 2026, closing the lid increasingly means "I'm walking to the next meeting while my agent finishes the PR." The OS hasn't caught up. Neither has the hardware: M-series chips can sustain a five-hour agent session on battery, but only if the system stays in a state Apple still treats as exceptional.

Community reaction on HN splits along two lines. The pragmatists are happy — *"finally"* appears in the top comments more than once. The purists argue this is a symptom of a larger architectural problem: long-running local agents shouldn't be tethered to your laptop's power state at all. They should run on a remote machine, in a container, in a cloud sandbox — anywhere but the device you carry. That argument has merit, but ignores the latency and filesystem-access reality of why people run agents locally in the first place. When your agent is editing your working tree, "just run it in the cloud" means "set up file sync that doesn't corrupt your git state," which is a harder problem than "keep the lid-closed laptop awake."

What this means for your stack

If you're regularly running Claude Code, Cursor background agents, Codex CLI, Aider, or any local LLM serving setup (Ollama, LM Studio) on a MacBook, Adrafinil is a 30-second install that closes a real ergonomic gap. It's a single Swift binary, MIT-licensed, no menu bar app, no telemetry.

A few practical notes from reading the source:

- Process matching is configurable. The default list covers the major agent CLIs and IDE helper processes, but you'll want to add your own if you run niche tooling. The config file lives at `~/.config/adrafinil/processes.txt`. - It uses `IOPMAssertionCreateWithName` correctly — meaning it shows up in `pmset -g assertions` so you can audit it. This is the right thing. Tools that hide their assertions are a debugging nightmare. - It does not prevent display sleep — only system sleep. Your screen still turns off, which means it doesn't keep the GPU spun up unnecessarily. - It does not handle clamshell-mode external displays specially. If you're docked, you probably don't need it.

The one thing missing — and the most-upvoted feature request in the HN thread — is a battery threshold. The author has already replied saying a `--min-battery 20` flag is coming, so the tool will release its sleep assertion if the laptop is about to brick itself in your bag. That's the right design: defense in depth against the exact Amphetamine failure mode it was built to avoid.

Looking ahead

The interesting question isn't whether Adrafinil ships v1.0. It's whether Apple notices. The number of developers running long-lived agent workloads on consumer laptops is growing fast enough that *"closed-lid background work"* is going to become a first-class OS feature within two macOS releases — either as an expanded Power Nap, or as a new entitlement that agent vendors can request. Until then, a 200-line Swift utility named after a nootropic is doing the work Cupertino hasn't gotten around to.

Hacker News 108 pts 71 comments

Show HN: Adrafinil – keep a lid-closed Mac awake only while agents work

A month ago there was a wave of posts and tweets about engineers walking around cafes and parks with their MacBooks propped half-open, as fully closing the lid forces sleep that stops their AI agents.

→ read on Hacker News
exabrial · Hacker News

Amphetamine is what I use. It has a robust set of triggers, like if you ip address changes to a certain subnet (like private IPs on a work network)https://apps.apple.com/us/app/amphetamine/id937984704?mt=12

chopete3 · Hacker News

This is great. Will check it.Recently I bought a usb-c empty external monitor card to prevent mac from going to sleep. There are many of these external monitor simulators on Amazon.I still see the laptop go to sleep many times with the external monitor simulator.This is the one I bought.4K 60Hz USB-

47 · Hacker News

I have been using the builtin macOS `caffeinate` command for this.For example:caffeinate -dimsuThat keeps the Mac awake so I can use Claude remotely from phone.You can also wrap your command as well, but I rarely use it.caffeinate -dimsu your-agent-command

processunknown · Hacker News

Does it also make my Mac irritable?

aqme28 · Hacker News

Thank goodness. I can’t leave my laptop for a second unattended because my cat loves nothing more than to dance on the keyboard. I’ve need something like this.

// share this

// get daily digest

Top 10 dev stories every morning at 8am UTC. AI-curated. Retro terminal HTML email.