Keeping (and losing) track of Mac sleep settings

Your Mac doesn’t have one kind of sleep—it has several. That fact is generally uninteresting until you find you can’t easily put your Mac into display sleep or system (idle) sleep automatically when you walk away from it or close a laptop’s lid. Let me help you help your Mac drift into the arms of Morpheus by digging beneath the surface.

Scattered sleep settings

Recently, I got frustrated with this recurrent problem on the Mac in my studio. Generally, I want this Mac’s displays to sleep and the system to lock, but to remain active, since I access it remotely and it handles networked Time Machine backups. I thought I’d correctly configured the various System Settings, scattered across different panes, several releases ago.

There are three settings to be aware of:

Lock Screen: In the System Settings app, select Lock Screen, note the “Turn display off… when inactive” setting or settings: “on battery” and “on power adapter” appear on a laptop; nothing on a desktop.1 You can choose an interval here. Never is an option, and could be your problem.

The Lock Screen pane in System Settings on a desktop Mac, where the display-sleep timers live.

Battery: On a laptop, go to the System Settings app and select Battery and click Options. There, you can enable “Wake for network access,” which is set to “Only on Power Adapter” by default, to wake your Mac as needed for certain incoming network traffic. Your Mac will wake up—and sometimes your display will, too. If set to Always, this can wake your laptop while it’s on battery power, and potentially leave its display active, which could drain your battery.

The Battery Options dialog on a laptop, where “Prevent automatic sleeping on power adapter when the display is off” and “Wake for network access” are configured.

Automatic sleeping: Apple enables a setting by default that keeps your Mac active when the display goes to sleep. The location and phrasing are slightly different between laptops and desktops. On a laptop, the setting is in Battery’s Options dialog, as above, and reads “Prevent automatic sleeping on power adapter when the display is off.” On a desktop, find it in the Energy preferences, where it’s called “Prevent automatic sleeping when the display is off.” Disable this switch if you want your Mac to sleep when the display powers down.

My Energy pane, in System Settings, shows the power adapter and UPS options, as I’m connected to a UPS.

Conversely, if you’d like a quick, manual way to put your display to sleep, you’ve got two options:

In the System Settings app, go to Desktop & Dock, click Hot Corners (found at the bottom), and choose Sleep as an action for one corner.

The Hot Corners dialog with the bottom-right corner assigned to Put Display to Sleep provides a quick way to sleep the display.

Press Control-Command-Q to activate Lock Screen, or choose Lock Screen from the Apple menu. I don’t love this keystroke, to be honest, because it’s perilously easy to type Command-Shift-Q, which logs you out of your account, shutting down all the apps.2

Unfortunately, tweaking these settings didn’t help my situation. The answer lay in Terminal, where I ran commands to reveal low-level information about what was keeping my Mac from display sleep.

Power management shows who’s keeping you awake

Apple does provide an excellent tool that shows what’s affecting power management and lets you control it: pmset.3 Even better, you can paste in the following to use that command to extract just sleep-related assertions, or activities that have an impact on sleep:

pmset -g assertions | grep -i sleep

When I typed this just now, I had a modest list, preceded by a summary:

PreventUserIdleDisplaySleep 0
PreventSystemSleep 1
PreventUserIdleSystemSleep 1
pid 507(coreaudiod): [0x00022a4d00018492] 00:36:44 PreventUserIdleSystemSleep named: "com.apple.audio.BuiltInHeadphoneOutputDevice.context.preventuseridlesleep"
pid 507(coreaudiod): [0x0001fc3c0001a751] 03:53:17 PreventUserIdleSystemSleep named: "com.apple.audio.BuiltInHeadphoneOutputDevice.context.preventuseridlesleep"
pid 64802(Music): [0x00022a4c00018a52] 00:36:45 PreventUserIdleSystemSleep named: "com.apple.Music.playback"
pid 35328(QuickTime Player): [0x000200bb0001894d] 03:34:06 NoIdleSleepAssertion named: "com.apple.QuickTimePlayerX - disable system sleep"
pid 68171(screensharingd): [0x00022c1e00078cbd] 00:28:59 PreventSystemSleep named: "Remote user is connected"
pid 437(powerd): [0x00022b5900018bb7] 00:32:16 PreventUserIdleSystemSleep named: "Powerd - Prevent sleep while display is on"

The first three lines tell me the off/on status as a 0 (off) or a count (1 per set of connected items) about whether any application or other process affects those categories:

PreventUserIdleDisplaySleep: When showing 0, as it is for me, there’s nothing that will block the display from sleeping on your Lock Screen delay choice. If this is 1 or higher, the display will not go to sleep.

PreventSystemSleep: A non-zero value, as in my case, means something is actively preventing the system from sleeping at all, even if I tried to put it to sleep manually.

PreventUserIdleSystemSleep: With a value of 1 or more, a process prevents your Mac, when idle, from engaging system sleep. If you perform an action, like choosing Sleep from the Apple Menu or closing the lid on a laptop, it will sleep.

You can see that I have several typical items in the filtered list below. The three lines listing com.apple.audio.BuiltInHeadphoneOutputDevice.context.preventuseridlesleep (twice) and com.apple.Music.playback relate to my current situation: I’m listening to the Music app via my Mac’s headphone jack, which is connected to speakers.

Maybe I shouldn’t have chosen the tea kettle from Amphetamine’s options for alternative menu bar icons?

I have no idea why QuickTime Player, shown next, would prevent idle sleep—that seems strange, as it was inactive and had no open files. Quitting it removed that assertion. (Apparently, the specific language it uses is a legacy assertion, so it isn’t properly counted in the summary.)

Screen Sharing (screensharingd) is also an odd duck. Normally, if you have a Screen Sharing session connected to your Mac, its display can go to sleep, but the system stays active. In this case, this is a transient state: I use Bartender, which has to use Screen & System Audio Recording, which appears as a form of screen sharing when active, to determine which system menu items are currently visible.

The final item, powerd, is the setting noted earlier: “Prevent sleep while display is on.”

When previously looking through this list, I came across an online reference to a Mac utility called caffeinate. Folks, I’ve said before I have to keep humble despite being a technology writer for what is now nearly 30 years: I had never seen this command-line tool before, to my knowledge, and, according to Google, I have never mentioned it in my archived writing.

caffeinate was introduced 13 years ago by Apple as a cutely named option you can use to keep the display awake. For instance, to keep the display forced awake for an hour, overriding other settings, enter:

caffeinate -d -t 3600

Now, I was aware of Amphetamine (free from the Mac App Store). But I didn’t quite understand—or, let me be honest, maybe have forgotten—that it performed the same function, relying on the same system hooks caffeinate employs, and putting a friendly menu bar wrapper around it.

Finding the caffeinate reference led me to look for Amphetamine, which in turn revealed the problem. Perhaps due to some errant menu bar clicking, I had activated Amphetamine, thus locking my display on. My confusion might stem from three factors. First, I forgot I had it installed. Second, I used Bartender to put the icon in its Hidden list, so it wasn’t displayed in the active bar. Third, I used the icon selection option to change the menu bar picture from a pill to a tea kettle—you know, drinking tea might keep you awake? I regret my decision, as I didn’t recognize what it was when I made that decision, seemingly years ago.

Unfortunately, I couldn’t just turn it off in the app—I had to quit the app, then toggle the active state to turn it off. Sadly, we humans can’t turn off our caffeinated mode to go to sleep.

[Got a question for the column? You can email glenn@sixcolors.com or use /glenn in our subscriber-only Discord community.]

I have an uninterruptible power supply (UPS), so I see “on power display” and “on UPS” (meaning when the UPS is actively providing power). ↩

If you have Keyboard Maestro, you can remap the Command-Shift-Q keystroke to do nothing or prompt you before logging out. ↩

You can use pmset to create limited sleep schedules, a feature available via System Preferences in macOS prior to Ventura. ↩