☾ 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
- Disables: idle system sleep, lid-close sleep, the Apple menu's Sleep command taking lasting effect.
- Doesn't disable: display sleep (your screen still turns off on schedule), screen lock, shutdown, restart, or thermal emergency shutdowns.
- Network stays up — downloads, servers and SSH sessions keep running with the lid closed. This is the main reason to use it; see overnight use.
Gotchas
- It persists across reboots. Nothing resets it. If you set it from Terminal and forget, your Mac never sleeps again until you undo it — which is why a visible indicator matters.
- A closed MacBook in a bag keeps running. It gets warm and drains the battery. Check the state before packing up.
- Battery drain is real: an awake, closed MacBook doing background work uses hours of battery where sleep would use almost none.
- It needs sudo every time, which makes frequent Terminal toggling tedious. SleepToggle installs a sudoers rule scoped to exactly these two commands so the toggle is one click.
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.