| ▲ | Show HN: Adrafinil – keep a lid-closed Mac awake only while agents work(github.com) | |||||||||||||||||||||||||||||||||||||||||||||||||
| 77 points by kageroumado 4 hours ago | 48 comments | ||||||||||||||||||||||||||||||||||||||||||||||||||
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). | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ▲ | exabrial 24 minutes ago | parent | next [-] | |||||||||||||||||||||||||||||||||||||||||||||||||
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) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ▲ | chopete3 4 hours ago | parent | prev | next [-] | |||||||||||||||||||||||||||||||||||||||||||||||||
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 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||||||||||||||||||||
| ▲ | 47 25 minutes ago | parent | prev | next [-] | |||||||||||||||||||||||||||||||||||||||||||||||||
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 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||||||||||||||||||||
| ▲ | aqme28 3 hours ago | parent | prev | next [-] | |||||||||||||||||||||||||||||||||||||||||||||||||
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. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ▲ | lellow an hour ago | parent | prev | next [-] | |||||||||||||||||||||||||||||||||||||||||||||||||
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. =) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ▲ | processunknown 4 hours ago | parent | prev | next [-] | |||||||||||||||||||||||||||||||||||||||||||||||||
Does it also make my Mac irritable? | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||||||||||||||||||||
| ▲ | geor9e 36 minutes ago | parent | prev | next [-] | |||||||||||||||||||||||||||||||||||||||||||||||||
Codex recently built this in - "Prevent sleep while running" toggle | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ▲ | mr_toad 2 hours ago | parent | prev | next [-] | |||||||||||||||||||||||||||||||||||||||||||||||||
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. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||||||||||||||||||||
| ▲ | rancar2 3 hours ago | parent | prev | next [-] | |||||||||||||||||||||||||||||||||||||||||||||||||
For MacOS, keep awake with: sudo pmset -a disablesleep 1 Reset back: sudo pmset -a disablesleep 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||||||||||||||||||||
| ▲ | dawnerd 4 hours ago | parent | prev | next [-] | |||||||||||||||||||||||||||||||||||||||||||||||||
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. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||||||||||||||||||||
| ▲ | IncreasePosts 25 minutes ago | parent | prev | next [-] | |||||||||||||||||||||||||||||||||||||||||||||||||
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 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ▲ | julianlam 42 minutes ago | parent | prev | next [-] | |||||||||||||||||||||||||||||||||||||||||||||||||
And the only thing | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ▲ | 2001zhaozhao 23 minutes ago | parent | prev | next [-] | |||||||||||||||||||||||||||||||||||||||||||||||||
We need people to rediscover remote development desperately, lol. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ▲ | slopinthebag an hour ago | parent | prev | next [-] | |||||||||||||||||||||||||||||||||||||||||||||||||
15k loc for this? holy cow | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ▲ | moralestapia 4 hours ago | parent | prev | next [-] | |||||||||||||||||||||||||||||||||||||||||||||||||
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. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||||||||||||||||||||
| ▲ | xlii 4 hours ago | parent | prev | next [-] | |||||||||||||||||||||||||||||||||||||||||||||||||
Um so it is
and
?(personally I have Ruby scripts that check activity on "tmux capture-output" for that) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||||||||||||||||||||
| ▲ | operatingthetan 4 hours ago | parent | prev | next [-] | |||||||||||||||||||||||||||||||||||||||||||||||||
So now we're naming apps after obscure Modafinil derivatives? | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||||||||||||||||||||
| ▲ | WUMBOWUMBO 3 hours ago | parent | prev | next [-] | |||||||||||||||||||||||||||||||||||||||||||||||||
reminds me of ye old caffeinate | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||||||||||||||||||||
| ▲ | cyanydeez 3 hours ago | parent | prev | next [-] | |||||||||||||||||||||||||||||||||||||||||||||||||
you can run opencode inside a docker container and expose it's webui. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ▲ | cyclopeanutopia 3 hours ago | parent | prev [-] | |||||||||||||||||||||||||||||||||||||||||||||||||
Ridiculous bloat. | ||||||||||||||||||||||||||||||||||||||||||||||||||