Lid closed? caffeinate can't. These flags block idle sleep. Closing a MacBook's lid without an external display sleeps the Mac anyway — that's a separate sleep path that power assertions don't cover. The only built-in override is the
pmset switch below, and it doesn't turn itself off. Why, in detail →pmset commands for the lid-closed case
Copy these as they are. They need an administrator password.
# disable all sleep, lid closed included (persistent!)
sudo pmset -a disablesleep 1
# check: 1 = sleep disabled, 0 = normal
pmset -g | grep SleepDisabled
# restore normal sleep — always run this afterwards
sudo pmset -a disablesleep 0
# what is keeping my Mac awake right now?
pmset -g assertions
If you'd rather not remember the last command, that's what Lidwork is for: it flips the switch from the menu bar and turns it back off on its own — when you toggle it, when the app crashes, and at your battery limit.
How to use the command
- Open Terminal (Spotlight → “Terminal”).
- Paste the command and press Return.
- Leave the window open. Press Control-C to stop, or let the time limit / command end.