disablesleep
v0.2.0
Published
A tiny, dependency-free macOS TUI for controlling caffeinate
Readme
disablesleep
A tiny, dependency-free macOS TUI for controlling caffeinate.
Run
npx disablesleepbunx disablesleepRequires macOS and Node.js 18+ or Bun. The terminal must be interactive.
Controls
Use ↑/↓ or j/k to move, Space or Enter to toggle, ←/→ or h/l to switch off/on, 1–5 to toggle a switch by number, r to refresh, and q or Esc to quit.
While a switch is paused by the current system state (for example, on battery with On battery off), the status line explains why. Colors follow your terminal and respect the NO_COLOR environment variable.
The switches control:
- Keep Mac awake: enable or release the sleep assertion.
- Allow lid closed: keep the policy active when macOS reports the lid is closed.
- On battery / On AC power: choose which power sources are allowed.
- While locked: continue asserting after the screen locks.
The TUI polls power, lid, and lock state while it runs. It uses caffeinate -s on AC power and caffeinate -i on battery power. No persistent pmset settings are changed.
Settings are saved automatically at ~/Library/Preferences/disablesleep.json and restored the next time you run the TUI.
The lid switch is intentionally best-effort. Apple documents that an idle-sleep assertion can still lose to forced sleep, including lid close. For reliable closed-lid use, use macOS closed-display mode with power and a supported external display, keyboard, or mouse.
Development
npm install
npm test
npm run build
node dist/bin/disablesleep.jsThe source is TypeScript; the published package contains compiled JavaScript and has no runtime dependencies. Publish with:
npm publishLicense
MIT
