How to prevent MacBook M2 Pro from sleeping with lid closed and display connected?

I've had an M2 pro for work for about 18 months.

This morning, my external display stopped working (connected via USB-C docking station, with DisplayLink). This has happened before, displaylink can be buggy, so I power cycled the dock and the mac, and all working again.


However, now the mac goes to sleep with the lid shut and display is connected. It's never done this to me before, it's always stayed on if an external display is connected.


I've done some googling, and checked various system settings:

  • Settings -> Battery -> Options -> Prevent automatic sleeping on power adapter (on)
  • Lock screen -> Turn display off on power adapter when inactive (never)
  • Display -> Options (could not find any relevant options)


Most google results say use amphetamine, or caffeine. Amphetamine works and stops it sleeping, so I know it's not a fault with my laptop. Just a bug in Apples OS.

Thing is, I don't really want to have to use 3rd party apps here there and everywhere, to get basic functionality working. I want to be able to configure this natively in the OS.


Does anyone know how to fix this?


[Re-Titled By Moderator]

Posted on Feb 21, 2025 1:05 AM

Reply
7 replies
Sort By: 

Feb 21, 2025 8:46 PM in response to DM-work

I was only providing it as an option since you mentioned you didn't want to rely on third party software. I also realize this is not ideal either, but at least it doesn't require a third party app. You could script it to make it easier to use.


If no one else provides any better options or solutions, then you can open a support case with Apple, or you can provide Apple with product feedback here (who knows what happens with the latter option):

Feedback - macOS - Apple


Reply

Feb 21, 2025 9:13 AM in response to HWTech

I was looking for something more along the lines of what I've already checked and configured:

  • Settings -> Battery -> Options -> Prevent automatic sleeping on power adapter (on)


caffeinate is an awful hacky workaround, and should not be necessary on 'pro' equipment.

Reply

Feb 21, 2025 9:06 AM in response to DM-work

You can use the built-in command line utility "caffeinate" to control some of these options.


Here is the command to prevent the display from sleeping:

caffeinate  -d


You can add an " &" to the end of the command to background that process so that Terminal window can be used for other things. Of course to terminate the command when in the background, you would need to either use Activity Monitor to quit the "caffeinate" process or issue another Terminal command to terminate the process:

pkill  caffeinate


If you did not background the caffeinate process, then just use Control + C when the caffeinate Terminal window has focus.


I think Amphetamine is just using this technique, but providing an easy to use interface.

Reply

Feb 24, 2025 12:55 AM in response to HWTech

I appreciate your response & the solution you came up with, but it's for experienced users or technically minded people.


The device should have a solution that your grandma can implement.


What's the phrase apple fanboys repeatedly say, "It just works"? Nothing works... Everything on this device needs fudging just to get some level of normal functionality.

Reply

Feb 24, 2025 7:13 PM in response to DM-work

DM-work wrote:

The device should have a solution that your grandma can implement.

FYI, That Apple no longer exists and has not for a long time now. Even I have trouble understanding some of the features in macOS and iOS. I have seen very knowledgeable forum contributors get into deep discussions about how a certain feature works....so if they cannot understand it clearly, the average user has no hope.


And many of Apple's error messages these days are usually cryptic at best, many are indecipherable.


I wouldn't hold your breath waiting for Apple to address any of these issues.


Reply

Feb 25, 2025 12:46 AM in response to HWTech

HWTech wrote:

I wouldn't hold your breath waiting for Apple to address any of these issues.


Me neither. I was hoping this thread would locate a sensible solution so other people from the internet can find and implement!


So far it looks like there's no native way to fix it. You cannot have your macbook in clamshell mode, because Apple decided you can't.


This is the problem with Apple. They think they know what you need, and force you down their path and into their walled garden. It's like with the keyboard. Apple do not know where the keys reside on my very standard british keyboard. Despite my OS being set to "British PC". I've had this keyboard for over 10 years, but on more than one occasion someone's suggested throwing it away for an Apple keyboard, just to have normal functionality. How wasteful!


That's the Apple mindset though. "Do it our way or struggle"


Reply

How to prevent MacBook M2 Pro from sleeping with lid closed and display connected?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.