☾ SleepToggle · pmset disablesleep reference

pmset disablesleep — the complete reference

The short answer: sudo pmset -a disablesleep 1 disables macOS system sleep entirely — idle sleep and the forced sleep from closing the lid — on every power source. sudo pmset -a disablesleep 0 re-enables it. The setting needs root, survives reboots, and the display still sleeps normally.

The commands

sudo pmset -a disablesleep 1   # system sleep OFF — stays awake, lid open or closed
sudo pmset -a disablesleep 0   # system sleep back to normal

-a applies the setting to all power sources (battery and charger). There is no per-source variant worth using here — a keep-awake switch you have to reason about per power source is a switch you'll get wrong.

Checking the current state

pmset -g | grep SleepDisabled
#  SleepDisabled        1     ← sleep is disabled
#  SleepDisabled        0     ← normal

No sudo needed to read it. This is exactly what SleepToggle's menu bar icon shows continuously: ☕ for 1, ☾ for 0.

What it does and doesn't affect

Gotchas

Relationship to caffeinate

caffeinate (and the apps built on the same power-assertion API — Amphetamine, KeepingYouAwake, Caffeine) prevents idle sleep only. Lid-close is forced sleep, which ignores assertions entirely. disablesleep is the only pmset setting that covers both. Full explanation: how to keep a MacBook awake with the lid closed.

A button for it

curl -fsSL https://sleep.138.dk/install.sh | bash

SleepToggle is a free, ~100-line open-source menu bar toggle for this setting — read the source, compiled locally on your own Mac.