pmset disablesleep: what it does and how to undo it
The one macOS setting that keeps a MacBook awake with the lid closed: how to turn it on, check it, turn it off, and what can go wrong.
By Harsh Soni, maker of Latte · Updated
sudo pmset -a disablesleep 1 stops a Mac from sleeping at all, even with the lid closed. sudo pmset -a disablesleep 0 puts it back. It stays on until you turn it off, so forgetting it is the main risk.
Turn it on, check it, turn it off
sudo pmset -a disablesleep 1 # no sleep, lid closed included
pmset -g | grep SleepDisabled # 1 = sleep is disabled, 0 = normal
sudo pmset -a disablesleep 0 # back to normal-a applies it on both battery and power. Use -c for power only, or -b for battery only. The setting isn't listed in pmset's manual page, so check it with pmset -g rather than assuming.
How it differs from the other sleep settings
| Setting or tool | Idle sleep | Lid closed |
|---|---|---|
| pmset sleep 0 | Never sleeps when idle | Still sleeps |
| caffeinate -i | Held while it runs | Still sleeps |
| Clamshell mode | Normal | Stays awake on power with a display |
| pmset disablesleep 1 | Never sleeps | Stays awake |
What can go wrong
- You forget it. The Mac never sleeps again until you run the off command. Check with
pmset -gif your battery life suddenly gets worse. - Heat. A closed MacBook in a bag or on a bed has nowhere to shed heat. macOS will throttle and, in the worst case, shut down to protect itself.
- Battery. On battery it runs until empty, which loses unsaved work and isn't kind to the battery.
Using it safely
- Keep the Mac on power and on a hard, open surface.
- Turn it off as part of the same command, so it can't be forgotten:
sudo sh -c 'pmset -a disablesleep 1; caffeinate -i -w <pid>; pmset -a disablesleep 0'That waits for the process with that ID to exit, then restores sleep. It won't run the last part if the Mac loses power or the terminal is killed, so still check afterwards.
A managed version of the same setting
Latte (which I make) uses this same setting through a small helper, but only while a coding agent is working. It turns it off when the work is done, at your battery floor, at critical heat, or within 30 seconds if Latte itself stops responding. More in keeping Claude Code running with the lid closed.
Common questions
- What does sudo pmset -a disablesleep 1 do?
- It stops a Mac from sleeping at all, including when you close the lid, on battery or on power. It stays that way until you run sudo pmset -a disablesleep 0.
- How do I check if disablesleep is on?
- Run pmset -g and look for the SleepDisabled line. 1 means sleep is disabled, 0 means the Mac sleeps normally.
- Is pmset disablesleep safe?
- It is safe on a desk with ventilation. The risk is forgetting it: a closed MacBook in a bag keeps running, gets hot and drains its battery. Always turn it off afterwards, or use a tool that does that for you.
Latte keeps Claude Code, Codex and Grok working with your MacBook closed, sends approvals to your phone, and lets the Mac sleep the moment the work is done.