Caffeinate is a small macOS app that stops your Mac from sleeping. A mug in the menu bar, a toggle, a timer. The built-in alternative is a terminal command with no interface; the other alternative is changing Energy Saver settings globally and forgetting you changed them.
The easy part was keeping the Mac awake. macOS hands you a power assertion and you hold onto it.
The hard part is letting go
Everything interesting in this app happens in the states where it has to give the power back. Closed-lid mode is the sharp version: it needs a root helper to disable lid sleep, which means the machine will now quite happily cook itself shut in a bag if the app ever fails to revert that setting.
So the helper resets on every startup and on every dropped connection. Quit it, crash it, kill -9 it — the setting comes back. That invariant is the product. A keep-awake app that occasionally forgets to stop is worse than no app at all.
Safeguards that hold their place
Battery and heat are vetoes, not off switches. When the battery drops past your cutoff, or the Mac runs hot with the lid shut, the session pauses but the reason stays. Plug in or cool down and it resumes on its own — you don't have to remember to switch it back on.
A small app whose entire design is about failing safely.
