Guide

A safer alternative to pmset disablesleep

Search for how to stop a Mac sleeping with the lid closed and you will be told to run sudo pmset -a disablesleep 1. It works. It is also a system-wide switch with no owner, no expiry and no memory of why you flipped it — which is why so many people meet it twice: once when they turn it on, and once when they are trying to work out why their Mac has not slept in a week. Here is what it actually does, how to undo it, and what a scoped version of the same idea looks like — the shape Perked was built around.

What the command actually does

Most keep-awake tools take a power assertion: a polite, per-process request that macOS weighs up along with everything else. disablesleep is not that. It sets a flag on the power-management system itself that says sleep is off — not idle sleep, not display sleep, all of it, including the sleep that normally happens when you close the lid.

That is why it is the answer people reach for: it is the only setting that gets lid-closed behaviour without an external display. It is also why it is dangerous as a default.

First: is it on right now?

Before anything else, check. If you have ever pasted that command, it may well still be set from months ago:

If SleepDisabled is 1 and you did not set it, some app did — a keep-awake utility with clamshell support almost certainly. That is not automatically wrong, but it should be an app you can point at, and one that clears the flag when it is finished.

caffeinate: lighter, and honest about its limits

The built-in caffeinate command is the right tool for most of what people use disablesleep for. It takes an assertion rather than flipping a global flag, needs no password, and — importantly — dies with the process that started it, so a closed terminal window cleans up after itself.

Where it stops: caffeinate cannot keep a MacBook awake with the lid closed. Nothing short of the disablesleep flag can. So the honest summary is that caffeinate is the safe option right up until the moment you need to shut the lid — and then you are back to the global switch, which is exactly the gap worth closing properly.

What a safe version of the same idea looks like

The flag is not evil; leaving it on is. So a safer version does not avoid disablesleep — it takes responsibility for it. Five properties are what separate the two:

How Perked does it

Perked keeps the flag but takes the footgun off it. The privileged part is a small helper that macOS installs as a system daemon — you approve it once in Login Items, and after that there is no admin password again. The app talks to it over XPC and asks for the flag only while a session is genuinely live.

The self-clearing property is the part worth spelling out, because it is the one you cannot build with a shell command: while keep-awake is on, the app sends the helper a heartbeat every 30 seconds. If the helper goes 90 seconds without one — the app crashed, you force-quit it, something went wrong — it turns sleep back on by itself. There is no state in which a dead Perked leaves your Mac permanently awake.

Around that sit the other four properties: it switches on when it detects a coding agent (or any process you nominate) and off when that finishes, it can require AC power or a battery floor you set, it pauses when the Mac runs hot, and it journals every switch so you can read back why a run ended. And because it is the same underlying flag, you can always audit it the same way — pmset -g | grep SleepDisabled while a session runs, and again after it ends.

Frequently asked

What does sudo pmset -a disablesleep 1 do?

It sets a system-wide power-management flag that disables sleep entirely — idle sleep, display sleep and lid-close sleep. It requires root, applies to the whole machine rather than one app, and stays set across reboots until you change it back.

How do I undo pmset disablesleep?

Run sudo pmset -a disablesleep 0, then confirm with pmset -g | grep SleepDisabled — it should print 0. Restarting the Mac does not clear it.

Is disabling sleep bad for a MacBook?

The flag itself does no damage; what it removes is a safety net. A Mac held awake cannot sleep when the battery runs low or when it is getting hot — and a closed laptop under load has very little room to shed heat. Keeping it on a hard surface with airflow, and only while work is actually running, is the difference that matters.

Is caffeinate a safe alternative?

For most cases, yes — it takes a per-process assertion, needs no password and stops when the command or process it is attached to ends. Its one hard limit is that it cannot keep a MacBook awake with the lid closed; only the disablesleep flag does that.

Can I keep my Mac awake with the lid closed without disabling sleep entirely?

Not with a different setting — lid-closed keep-awake without an external display is exactly what that flag controls. What you can change is the scope: set it only while a job is running and clear it immediately afterwards, with a watchdog that restores sleep if the app supervising it dies. That is what Perked does.

What happens if the app that set the flag crashes?

With a raw shell command, nothing — the flag stays on until someone notices. Perked’s helper expects a heartbeat every 30 seconds and re-enables sleep by itself if 90 seconds pass without one, so a crash or a force-quit restores normal behaviour on its own.

The scoped version of the same flag

Lid-closed sessions that switch themselves off — power-aware, thermal-aware, and self-clearing if the app dies. One-time €1.

See pricing →

Related guides

The full clamshell walkthrough: Keep your MacBook awake with the lid closed →

The lighter tool, flag by flag: The macOS caffeinate command →

Something already holding your Mac up? What is keeping your Mac awake? →

← Back to Perked