Back to News
Advertisement
kkageroumado about 2 hours ago 33 commentsRead Article on github.com

FR version is available. Content is displayed in original English for accuracy.

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. Some people made snarky comments about using tmux or Amphetamine, and some defended their choice with “but I only need it sometimes, and forgetting to disable Amphetamine and finding my laptop discharged in my bag is worse.”

This is a solution to this problem. Unlike caffeinate, it will prevent your MacBook from sleeping even with the lid closed, with no external power or display, using pmset disablesleep 1. Unlike other sleep-preventing apps, Adrafinil only activates when there’s an agent actively doing something. It detects agent activity through hooks it installs into Claude Code, Codex, and others. To reassure you it’s working, the app shows the active status in the menu bar, and it plays a chime when you close the lid.

Once the agent is done, Adrafinil detects it and lets the laptop go to sleep by setting pmset disablesleep back to 0. It will also let it sleep in case of overheating. And if you want to manually toggle it, you can install an optional MCP and tell your agent to keep the MacBook awake for a specific time.

It has four binaries, one of which is a root helper exposing a single setSleepBlocked call. All the logic and policy live in the unprivileged parts. They’re all notarized, and the app is fully open source (MIT).

Advertisement

⚡ Community Insights

Discussion Sentiment

100% Positive

Analyzed from 555 words in the discussion.

Trending Topics

#sleep#laptop#app#pmset#agent#done#need#disablesleep#check#external

Discussion (33 Comments)Read Original on HackerNews

chopete3about 2 hours ago
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-C Type-C Virtual Display Adapter DDC EDID Dummy Plug Headless Ghost Display Emulator 2K 60hz1080P@120Hz

kageroumadoabout 1 hour ago
The dummy display enables “clamshell mode,” which lets your MacBook stay awake even with the lid closed, provided that it’s also on AC power. If the MacBook is not connected to power, the clamshell mode isn’t activated and it will sleep normally.

Adrafinil simply disables the global sleep without spoofing hardware, and re-enables it once the agent is done working, the temperature is too high, or the battery is low.

chopete332 minutes ago
My requirement was to keep the laptop on with the lid closed. Sleep normally when idle but wake up when a nomachine request comes in.

I will see how this app fits into my specific need.

I have to check this on Mac Sequoia 15.7

kageroumado9 minutes ago
The app is built for 26+, as I never tested it on earlier versions. It won’t solve your specific case, though, as it only prevents sleep. It won’t wake it once it’s already sleeping.
bluedinoabout 1 hour ago
Can't you just use a hot corner configured as "prevent sleep"?
fragmedeabout 1 hour ago
How does it sleep when the agent is done working with the hot corner?
doubled112about 1 hour ago
Have the agent write an app that moves the cursor our of the hot corner and trigger it when done.
aqme28about 1 hour ago
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.
rancar2about 1 hour ago
For MacOS, keep awake with:

sudo pmset -a disablesleep 1

Reset back:

sudo pmset -a disablesleep 0

kageroumadoabout 1 hour ago
This is exactly what the app does, except it ties it to agent activity and re-enables sleep once the turn ends, the laptop is close to overheating, the battery is low, or on a timer.
xbarabout 1 hour ago
Nice. I needed this yesterday, and will need it again today.
processunknownabout 2 hours ago
Does it also make my Mac irritable?
kageroumadoabout 2 hours ago
Probably less irritable than amphetamine~
dawnerdabout 2 hours ago
But Amphetamine has an option to end when an app closes. I’m just so confused why everyone using ai is reinventing solutions that already exist.
kageroumadoabout 1 hour ago
Claude Code or Codex (normally) don’t close the terminal window after a turn ends, they wait for the user’s reply.
neoecosabout 1 hour ago
I think the same...It happend to me that I just ask Claude to build whatever I need for my personal very specific use case without looking what else it's outhere
flexagoonabout 1 hour ago
Everyone dreams about making the next cool AI tool and doesn't bother checking if someone has already made the same thing years ago without the word "AI" in the description
conceptionabout 1 hour ago
Easier to ask Claude than ask google I guess.
xliiabout 2 hours ago
Um so it is

    sudo bash -c 'touch KEEP_RUNNING; pmset -b sleep 0; pmset -b disablesleep 1; while [ -e KEEP_RUNNING ]; do sleep 1; done; pmset -b sleep 5; pmset -b disablesleep 0'
and

    Agent, when you're done do `rm KEEP_RUNNING`, kthxbye.
?

(personally I have Ruby scripts that check activity on "tmux capture-output" for that)

da_grift_shiftabout 1 hour ago
moralestapiaabout 2 hours ago
What's old is new again, but I welcome this.

I used to do this 15 years ago to keep listening to music from my laptop (one of the white chiclet ones) in my backpack, can't remember the name of the app I used then.

One caveat, your laptop cannot cool inside a backpack, it will overheat and shut down anyway. This happened to me several times.

kageroumadoabout 2 hours ago
It has a setting for thermal cutoff that you can set to something like 60º C. Sleeping will stop heavy work (like a build) before it leads to overheating.
dmdabout 2 hours ago
that was true of intel but definitely not of arm macbooks.
NewJazzabout 2 hours ago
Then why do they have fans?
dominotwabout 2 hours ago
had a coworkers whose laptop keys melted into mush
WUMBOWUMBOabout 2 hours ago
reminds me of ye old caffeinate
kageroumadoabout 1 hour ago
Caffeinate doesn’t prevent sleep with the lid closed.
operatingthetanabout 2 hours ago
So now we're naming apps after obscure Modafinil derivatives?
unacornerabout 1 hour ago
Adrafinil's discovery and use predates Modafinil, I believe.
operatingthetan38 minutes ago
I admire your pharma knowledge.
cyanydeezabout 1 hour ago
you can run opencode inside a docker container and expose it's webui.
cyclopeanutopiaabout 2 hours ago
Ridiculous bloat.
Advertisement