Stop Your MacBook From Sleeping With a Caps Lock Toggle
For those of us running local LLM agents or long-running data pipelines, the macOS "sleep on lid close" behavior is a constant friction point. While most developers default to the caffeinate command in the terminal to prevent sleep, that approach is cumbersome for quick toggles and requires keeping a terminal window active.
I've been testing Capsomnia, a lean utility that maps the system's "awake" state directly to the Caps Lock key. It effectively turns a hardware toggle into a power management switch, allowing your MacBook to stay active even when the lid is closed.
Why this beats the standard caffeinate workflow
In a standard dev environment, if you need to keep a process running while moving from your desk to a meeting, you'd typically run:
caffeinate -i
While effective, you then have to remember to kill that process manually once you're back, or risk draining your battery throughout the night. Capsomnia removes this cognitive load. By granting the app Accessibility permissions in System Settings, the Caps Lock key becomes a physical indicator of your machine's power state. If the light is on, the machine stays awake; if it's off, macOS follows its standard energy-saving profile.
Real-world application: AI Workflows and Headless Setups
This is particularly useful for AI engineers running local inference. If you are executing a complex chain of prompts via a local agent that takes 10 minutes to complete, the last thing you want is for the system to enter a low-power state the moment you close the lid, which often kills the active socket connection or pauses the Python process.
By toggling Caps Lock, you ensure the CPU continues to cycle through the task without needing to dive into the "Battery" or "Displays" section of System Settings to manually adjust "Prevent automatic sleeping when the display is off."
Setup and Implementation
The installation is minimal and doesn't bloat your system resources:
1. Install the utility and launch it.
2. Navigate to System Settings > Privacy & Security > Accessibility.
3. Toggle the switch to allow the app to monitor keyboard input.
4. Use the Caps Lock key as your "Stay Awake" trigger.
For anyone who treats their MacBook as a temporary server or a headless node for home automation, this is a significant quality-of-life improvement. It transforms a largely redundant key into a functional tool for power management, providing a tactile confirmation that your background renders or deployments won't be interrupted by the OS's aggressive sleep timers.
All Replies (4)
Does this mess with any specific keyboard shortcuts or just the sleep timer?
@PatFounder Probably, but who knows? I'd be worried about it triggering some random system command while I'm typing.
Just a heads up, this might cause screen burn-in if you leave it on too long.
Works for me, but make sure your charger is plugged in so it doesn't die.