Capsomnia
Turn the Caps Lock key into a physical macOS sleep-prevention switch so background tasks keep running with the lid closed.
About Capsomnia
Capsomnia is a free, open-source macOS menu bar utility that turns the Caps Lock key into a physical sleep-prevention switch: on prevents system sleep, while off restores normal sleep behavior. Choose a 15-minute to 8-hour preset or a custom duration from 1 minute to 24 hours; when it ends, the tool confirms that sleep prevention is released and then puts the Mac to sleep automatically. The menu bar app runs as the current user and changes sleep settings through a fixed root-owned helper, with normal sleep restored when the app exits. It is suitable for long-running background tasks such as Codex and Claude Code with the lid closed; the official guidance warns that this can increase heat and power use, so monitor cooling, power, and runtime.
Best for
Best use cases
Close the lid and let long-running Codex or Claude Code tasks continue
Set a 15-minute to 8-hour preset or a custom 1-minute to 24-hour duration, then sleep automatically
Temporarily prevent Mac sleep, then turn off Caps Lock to restore normal sleep
Features
Physical sleep-prevention switch
Turns the Caps Lock key into a switch: on prevents system sleep, while off restores normal sleep behavior.
Flexible timer control
Choose a 15-minute to 8-hour preset or a custom duration from 1 minute to 24 hours; the Mac sleeps automatically when it ends.
Transparent security model
The menu bar app runs as the current user and uses a fixed root-owned helper with passwordless sudo to modify sleep settings.
Free and open source
Open source under the MIT license, with the source code, install script, helper command, and security model available for review before installation.
Pros
- Completely free and open source under the MIT license, with reviewable source code and security model
- Toggle sleep prevention with one key for intuitive control
- Supports 15-minute to 8-hour presets and custom durations from 1 minute to 24 hours
- Runs as the current user and automatically restores normal sleep behavior on exit
Cons
- Running with the lid closed and sleep disabled can increase heat and battery use; monitor cooling, power, and runtime
- Requires macOS 14 or later