alt.hn

6/27/2026 at 8:34:53 PM

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

https://github.com/kageroumado/adrafinil

by kageroumado

6/28/2026 at 12:26:26 AM

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

by exabrial

6/28/2026 at 4:53:26 AM

Came to say this. I've used it for years. Simple and works great!

by anonuser123

6/27/2026 at 9:17:47 PM

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

by chopete3

6/27/2026 at 9:57:25 PM

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.

by kageroumado

6/27/2026 at 10:24:01 PM

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

by chopete3

6/27/2026 at 10:47:04 PM

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.

by kageroumado

6/27/2026 at 9:35:00 PM

Can't you just use a hot corner configured as "prevent sleep"?

by bluedino

6/27/2026 at 9:36:24 PM

How does it sleep when the agent is done working with the hot corner?

by fragmede

6/27/2026 at 9:42:42 PM

Have the agent write an app that moves the cursor our of the hot corner and trigger it when done.

by doubled112

6/27/2026 at 9:54:07 PM

[dead]

by darig

6/28/2026 at 12:25:15 AM

I have been using the builtin macOS `caffeinate` command for this.

For example:

caffeinate -dimsu

That 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

by 47

6/28/2026 at 12:38:31 AM

Caffeinate is burned into my muscle memory at this point. I attribute that to the realization that you could repeat opt flags. There's something catchy about

caffeinate -dimsum

by zxexz

6/28/2026 at 1:37:22 AM

Claude Code actually uses caffeinate -i -t 300 during Claude’s turn, restarted automatically until the turn finishes.

by kageroumado

6/28/2026 at 1:41:07 AM

The new wave apps named after speed / modifinil must be hard core?

by steve-atx-7600

6/27/2026 at 8:53:56 PM

Does it also make my Mac irritable?

by processunknown

6/28/2026 at 1:50:57 AM

I guess we are getting the entire modafinil, R-modafinil extended universe.

by loeg

6/27/2026 at 9:24:05 PM

Probably less irritable than amphetamine~

by kageroumado

6/27/2026 at 9:38:25 PM

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.

by aqme28

6/27/2026 at 9:20:00 PM

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.

by dawnerd

6/27/2026 at 9:28:16 PM

Claude Code or Codex (normally) don’t close the terminal window after a turn ends, they wait for the user’s reply.

by kageroumado

6/27/2026 at 9:51:03 PM

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

by neoecos

6/27/2026 at 9:27:45 PM

Easier to ask Claude than ask google I guess.

by conception

6/27/2026 at 9:44:03 PM

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

by flexagoon

6/27/2026 at 11:04:40 PM

In order to get the same behavior with Amphetamine you’ll need to: 1. Install it from the AppStore (no brew, no GitHub) 2. Not forget to enable lock on lid close 3. If you ever connect/disconnect power while the lid is closed without the optional “Power Protect” system, the MacBook will sleep. The system is a script and a configuration file making sudo pmset -a disablesleep passwordless. 4. Add hooks to Claude Code configuration that will use Apple Script to start and stop Amphetamine sessions. For Codex you’ll have to make a script that will watch process activity to know when a turn ends.

It’s not like Amphetamine can’t do the same, it’s that this app is made specifically for AI agents and nothing else.

by kageroumado

6/27/2026 at 9:38:57 PM

For MacOS, keep awake with:

sudo pmset -a disablesleep 1

Reset back:

sudo pmset -a disablesleep 0

by rancar2

6/27/2026 at 9:46:20 PM

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.

by kageroumado

6/27/2026 at 9:48:54 PM

Nice. I needed this yesterday, and will need it again today.

by xbar

6/28/2026 at 12:36:07 AM

This works great. Only downside is display doesn't turn off when you close the lid. Made a little status bar utility to wrap the disablesleep command and address that downside:

https://github.com/narcotic-sh/modafinil

(yes, I know, another *afinil named Mac sleep prevention app? but hey, I was first :P)

by hamza_q_

6/28/2026 at 3:56:59 AM

Just tried. Bare minimal and does exactly what's needed and nothing else. Love it. Thanks..

by freakynit

6/28/2026 at 4:14:58 AM

np cheers mate

by hamza_q_

6/28/2026 at 1:23:24 AM

Afinils are cool, and your app is cool too~

by kageroumado

6/28/2026 at 3:34:26 AM

Indeed.

Thanks!

by hamza_q_

6/27/2026 at 11:25:14 PM

Interesting. Kind of similar in purpose, but I created a simple app to schedule and type the "continue" word in my terminal after X time has passed, since I have to wait for my usage to be restored. =)

by lellow

6/28/2026 at 5:18:21 AM

Does closing the M-series laptop lid no longer throttle the CPU like it did on the Intel ones?

by dcan

6/27/2026 at 10:56:40 PM

I’ve often wondered about the thermal performance or running a MacBook with the lid closed. One argument is that the reduced surface area from a closed lid increases temperature. Others argue that not running & rendering the display (and thus GPU) generates less heat. I’m not sure who to believe.

by mr_toad

6/28/2026 at 12:52:38 AM

How does this differ from https://github.com/samber/cc-caffeine?

by AussieWog93

6/28/2026 at 1:29:40 AM

It’s an Electron app that uses powerSaveBlocker to prevent display sleep. It won’t prevent macOS system sleep on lid close with no power.

by kageroumado

6/28/2026 at 4:29:58 AM

Thanks. This one looks much better!

by AussieWog93

6/28/2026 at 3:28:49 PM

> 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

Why don’t they just ask the agents to code up something to prevent the Mac sleeping.. and that will auto enable/disable depending on if they have the agent running or not

I mean, agents makes human devs redundant, right? This seems like a trivial little problem for an agent to fix

by Msurrow

6/28/2026 at 5:09:19 AM

Adrafinil never seemed to work for me. I tried it a few times when I worked an overnight shift.

by NDlurker

6/28/2026 at 4:37:28 AM

It would be great if adrafinil can also track the battery and token usage while agents are working

by tam159

6/27/2026 at 9:13:07 PM

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)

by xlii

6/28/2026 at 6:15:11 AM

I am always baffled how many people does not know about Amphetamine.

by strus

6/28/2026 at 12:14:33 AM

Codex recently built this in - "Prevent sleep while running" toggle

by geor9e

6/28/2026 at 12:04:09 AM

15k loc for this? holy cow

by slopinthebag

6/27/2026 at 8:57:10 PM

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.

by moralestapia

6/27/2026 at 9:22:12 PM

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.

by kageroumado

6/27/2026 at 9:07:54 PM

that was true of intel but definitely not of arm macbooks.

by dmd

6/27/2026 at 9:14:25 PM

Then why do they have fans?

by NewJazz

6/28/2026 at 1:52:04 AM

Many ARM Macbooks do not have fans?

by loeg

6/28/2026 at 8:04:13 PM

Many do. I would argue most do, although i don't have air vs. Pro sales numbers so I can't speak definitively there.

Even those that don't may rely on passive cooling strategies that are less effective in enclosed spaces.

by NewJazz

6/27/2026 at 9:07:29 PM

had a coworkers whose laptop keys melted into mush

by dominotw

6/27/2026 at 9:16:08 PM

So now we're naming apps after obscure Modafinil derivatives?

by operatingthetan

6/28/2026 at 12:11:24 AM

I'll take credit for starting this trend :P

https://github.com/narcotic-sh/modafinil

by hamza_q_

6/28/2026 at 3:23:14 AM

There were mac apps called caffeine and amphetamine years ago.

by operatingthetan

6/28/2026 at 5:56:35 AM

In that case from what I understand, Adrafinil has a much lower abuse potential than amphetamines, in particular because it doesn't give you a rush. If we're going to name mac apps after pharmaceuticals then this feels a little bit classier. No rush, just steady wakefulness.

by oenton

6/28/2026 at 3:34:08 AM

Was referring to the *afinil specifically

by hamza_q_

6/28/2026 at 3:36:18 AM

Alright, well I guess I thought were were talking about naming apps after stimulant drugs lol.

by operatingthetan

6/28/2026 at 4:16:54 AM

[dead]

by hamza_q_

6/28/2026 at 12:37:20 PM

I thought it was related to sildenafil and gives the laptop an erection lol

Maybe as a metaphor that you can't close the lid cuz the boner is in the way and keeps it awake

by hoppp

6/27/2026 at 10:09:39 PM

Adrafinil's discovery and use predates Modafinil, I believe.

by unacorner

6/27/2026 at 10:18:35 PM

I admire your pharma knowledge.

by operatingthetan

6/28/2026 at 3:25:52 AM

`sudo pmset -a sleep 0`

by kylehotchkiss

6/28/2026 at 12:27:15 AM

We need people to rediscover remote development desperately, lol.

by 2001zhaozhao

6/28/2026 at 12:25:45 AM

At some point, if you closed the lid and didn't have an external monitor plugged in, macos would put the GPU in power save mode, which would tank local llm performance. Is that not the case any more? There were even small singles you could get which would trick the ps into thinking an external monitor was plugged in

by IncreasePosts

6/28/2026 at 1:52:39 AM

I don't think this is for running local llms.

by loeg

6/27/2026 at 9:26:11 PM

reminds me of ye old caffeinate

by WUMBOWUMBO

6/27/2026 at 9:43:04 PM

Caffeinate doesn’t prevent sleep with the lid closed.

by kageroumado

6/27/2026 at 9:56:29 PM

you can run opencode inside a docker container and expose it's webui.

by cyanydeez

6/28/2026 at 3:00:19 PM

[flagged]

by impartshadow

6/28/2026 at 5:25:44 AM

[flagged]

by VaporJournalAPP

6/28/2026 at 2:31:56 AM

[dead]

by tangweigang

6/27/2026 at 11:01:09 PM

[flagged]

by rnagulapalle

6/27/2026 at 10:39:48 PM

[dead]

by huflungdung

6/28/2026 at 7:27:57 AM

[dead]

by shobhit98

6/27/2026 at 9:24:26 PM

Ridiculous bloat.

by cyclopeanutopia