Keep awake only while agents work

Keep your computer awake while an agent, the queue or a workflow runs, then let it sleep. Shuriken's two settings: While working and Always.

WHILE WORKING beside a real screenshot of Shuriken's Keep awake setting: awake while three chats run, under "Keep awake only while agents work"
Contents

Give an agent a long task and go for coffee, and the computer can be asleep four minutes in, with the agent stopped mid-thought. We kept hearing about it, and we kept doing it ourselves.

The usual fix is an app like Amphetamine, switched on and left on. Then the laptop never sleeps at all, and you find out later from a warm bag and an empty battery. We wanted less than that: awake while an agent works, asleep once it stops. In Shuriken that's a mode called While working.

Two settings#

Each of your computers has a Keep awake setting on its page under Settings › Devices. Always means the computer never idles off, so your phone and your other computers can reach it at any hour. While working is the lighter one: awake while there's work, normal sleep when there isn't. There's no Off. A computer never naps while something in Shuriken is working, whichever you pick.

New computers start on Always, because a computer you can't reach from your phone is no use to you. A laptop you carry around is different; put it on While working and it naps between jobs.

What counts as "working"#

"While working" has a precise meaning. Shuriken holds the computer awake when any of these is true:

  • an agent is running a turn in one of your chats;
  • a chat still has background work going: subagents, a workflow run, a shell command;
  • the queue has a message waiting to send or sending.

Once none of that is true, Shuriken lets go and your normal sleep settings apply again. It re-checks whenever an agent or the queue changes, and every 30 seconds on top of that, because background work sometimes finishes without saying so.

Agent work runs three times between 13:00 and 17:00. While working holds the computer awake only during those three stretches. Always holds it awake all afternoon; the screen can still turn off. 13:0014:0015:0016:0017:00Agent workWhile workingAlwaysAwake all afternoonAgent turn, workflow or queued messageComputer held awake

Neither setting keeps the display on. The screen still turns off. If Shuriken crashes, the hold goes with it: the small process holding the computer awake watches Shuriken and exits when Shuriken does. You won't come back on Monday to a laptop that stayed up all weekend.

Shuriken uses each system's own switch for this: caffeinate on macOS, systemd-inhibit on Linux and the Windows power API on Windows. Both settings work on all three.

How this differs from Cocaine mode#

Keep awake stops idle sleep with the lid open. It does not help when you close a MacBook and put it in your bag: on a normal setup, closing the lid sleeps a Mac whatever an app asks for.

That is what Cocaine mode is for. Yes, that is really its name. It lives behind the syringe in the top bar, and yes, its per-device switch is also labelled Keep awake, which we'll grant is one Keep awake too many. You choose which computers it covers, and on a Mac those keep running with the lid shut. Setting it up asks for an administrator password once. You can take that permission back later, and the mode stays on until you switch it off. Close the lid, walk to the train, and your agents are still typing (the lid-closed setup is in keeping Claude Code running with the lid closed).

So the two work together. Keep awake answers "don't nap while I'm out of the room", and Cocaine mode answers "keep going while the laptop is shut in my bag".

Cocaine mode's lid-closed promise started on the Mac. Shuriken 5.1 brought Cocaine mode to Windows and Linux too. Laptops differ there, so each device says what it can do: "Keeps running with the lid closed", "needs a one-time permission" for the lid, or "No lid setting found". On Linux it needs systemd-logind. The Cocaine mode page has the details.

Battery and heat: which to pick#

A computer that can't sleep draws power and gets warm. On battery, in a bag, we'd pick While working, since it only holds the computer during real work and a finished task doesn't eat the rest of your charge. Shuriken can also tell you if the charger comes out or the battery runs low while agents work (Settings › Notifications).

Plugged in at a desk, leave it on Always (the default) if you might check in from your phone later, and use While working if you won't. Desktops and servers that your other devices need to reach should stay on Always. A laptop that travels shut needs Cocaine mode, and some care about heat: a closed laptop in a soft bag has nowhere to send it.

Coming from Amphetamine? Amphetamine alternatives for coding agents puts it next to the other options. To see what's keeping your computer awake right now, open Activity: every running agent, workflow and background command is listed there.

Every computer you sign in starts on Always, and moving a laptop to While working is one click. Try Shuriken.

Frequently asked questions

Which Keep awake setting should I pick?

For a laptop you carry, While working: it only holds the computer awake while an agent, the queue or a workflow is running. For a computer you want to reach from your phone at any hour, Always, which is the default.

Does keep awake also keep the screen on?

No. It only stops the computer from sleeping. The display still turns off on its usual timer.

What happens if Shuriken crashes while it holds the computer awake?

The hold ends with it. The process that keeps the computer awake watches Shuriken and exits when Shuriken goes, so a crash never leaves a computer that cannot sleep.

Is this the same as Cocaine mode?

No. Keep awake stops idle sleep while the lid is open. Cocaine mode is the stronger promise: chosen computers keep running even with the lid closed.

Free tools