FR version is available. Content is displayed in original English for accuracy.
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).

Discussion (33 Comments)Read Original on HackerNews
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
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.
I will see how this app fits into my specific need.
I have to check this on Mac Sequoia 15.7
sudo pmset -a disablesleep 1
Reset back:
sudo pmset -a disablesleep 0
(personally I have Ruby scripts that check activity on "tmux capture-output" for that)
https://ghloc.vercel.app/kageroumado/adrafinil?branch=main
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.