Closing a MacBook lid normally puts the Mac to sleep. If you need a task, download, or remote session to continue while the lid is closed, you can disable system sleep with pmset.
Important: This setting disables sleep system-wide, not only lid-close sleep. It can increase battery use and heat. Keep the Mac on a hard, ventilated surface, never leave it running in a bag, and restore normal sleep when you are finished.
Keep the Mac awake with the lid closed
Open Terminal (Applications > Utilities > Terminal), then run:
sudo pmset disablesleep 1
Enter your administrator password when prompted. Terminal does not display characters while you type the password.
Restore normal sleep
Re-enable sleep as soon as you no longer need the Mac to stay awake:
sudo pmset disablesleep 0
You can check the current power-management settings with:
pmset -g
Using a MacBook with the lid closed and an external display
If your goal is a normal desktop setup, use Apple's closed-display mode instead of disabling sleep globally: connect the Mac to power, an external display, and an external keyboard and mouse or trackpad. This is the safer choice for routine desk use.
Do you mean “stop the Mac from turning on when I open the lid”?
Sleep and automatic startup are different settings. On a Mac laptop with Apple silicon running macOS Sequoia 15 or later, this command prevents startup only when the lid is opened:
sudo nvram BootPreference=%01
To restore automatic startup:
sudo nvram -d BootPreference
Apple also documents %00 to prevent startup both when opening the lid and when connecting power, and %02 to prevent startup only when connecting power. These BootPreference options require Apple silicon and macOS Sequoia 15 or later.
Source: Apple Support: Prevent a Mac laptop from turning on when opening its lid or connecting to power.

Comments