Skip to main content

SleepSwitch: macOS menu bar app to keep AI agents running

SleepSwitch is a macOS menu bar utility that prevents your MacBook from sleeping when the lid is closed, solving interrupted AI coding agent tasks.

AI-written
Inewgen
29 Aug 2026Source: Dev.to2 min read (0 views)
Share
SleepSwitch: macOS menu bar app to keep AI agents running

Stock photo for illustration only, not from the actual event

Font size
  • SleepSwitch prevents your Mac from sleeping even when the lid is closed.
  • It bypasses standard caffeinate limitations regarding lid-closed sleep.
  • Includes a Battery Guard feature to prevent overheating inside bags.
  • Created by Dmitry Ganin to handle long-running AI coding agent tasks.

Running background tasks like Claude Code refactoring a service or Codex running a test suite often requires walking away and closing the laptop lid. However, closing the lid causes macOS to sleep instantly, killing active sessions, wiping out the AI's context, and ruining uncommitted work.

Standard commands like caffeinate -dimsu fail the moment the lid closes because lid-closed sleep is governed by a separate system setting requiring root access via sudo pmset -a disablesleep 1. This workflow forces developers to remember flags, type passwords, and risk letting the laptop run hot inside a closed bag.

macbook pro notebook computer workspace close up

Stock photo for illustration only, not from the actual event

As developers increasingly rely on autonomous AI agents for heavy coding tasks, standard operating system power management policies often get in the way. Tools like SleepSwitch bridge the gap between aggressive OS power-saving features and the need for uninterrupted developer workflows.

Never miss the latest news?

Subscribe to get news summaries by email - not often enough to be annoying.

โฆษณา

"This started as a "keep the build running" utility. Then AI coding agents happened, and it turned out they're the worst possible workload for macOS power management."

Dmitry Ganin

Developer Dmitry Ganin created SleepSwitch to handle this workflow with a single menu bar click. Left-clicking toggles the mode, while right-clicking opens settings. Closing the lid with the mode active emits a muted porcelain tone, confirming the machine remains awake.

20%Default battery threshold to automatically disable SleepSwitch

To prevent overheating inside a backpack, SleepSwitch features a Battery Guard that automatically disables the mode once the battery drops to a configurable threshold (defaulting to 20%) or when the power adapter is unplugged. The project is available on GitHub for users looking to manage long runs safely.

Source: Dev.to

Comments

Leave a Comment
0/2000

Found something wrong in this article? Report an issue with this article