The annoying difference between idle sleep and lid-close sleep on macOS
by•
I kept seeing `caffeinate` suggested under long-running agent threads, so the short version is: it prevents idle sleep. Closing the lid uses a different macOS sleep path, which is why a build or agent can still stop the second you shut the MacBook.
If you only need to lock the screen or walk away with the lid open, `caffeinate -i` is enough. For closed-lid work, you need something that changes the lid behavior and, just as importantly, restores it afterwards. That distinction is what pushed me to build Clamshell.
Curious how other people handle long local agent jobs: leave the lid cracked, use cloud agents, or change the Mac’s sleep behavior?
11 views


Replies
my previous answer to this was `sudo pmset -a disablesleep 1` before closing the lid, then remembering to flip it back after, which is exactly the kind of manual step that gets skipped the one time you're in a rush and end up with a laptop that won't sleep on the train either. the "restores it afterwards" part is the actual product to me, not the not-sleeping part - the raw pmset flag has been sitting in terminal history for years, the annoying bit was always cleanup. does Clamshell hook into wake/lid-open to flip the setting back automatically, or is it watching for something else like AC power getting unplugged?
Clamshell
Yep, that cleanup is the whole point for me. In the default mode, opening the lid returns the Mac to normal lid behavior. Power and wake changes are handled in the background so it doesn’t quietly end up looking armed when it isn’t.