Insomnia keeps a Mac awake for a timed agent session
Insomnia, a free MIT-licensed macOS menu bar app by a developer publishing as krishhgg, keeps a MacBook awake for a timer the user sets and ends the session on its own, with lid-close behaviour, a recovery agent and battery and thermal limits. The repository has 468 stars on GitHub and ranked eighth on Trendshift's daily list on 10 October.
Image: GitHub
Why it mattersAn agent run that needs a laptop awake for several hours either keeps the screen on all night or ends halfway through sleep, and a timed sleep lock with a recovery step lets a reader leave a run on the kitchen table and get the result in the morning.
Starting an overnight run of a coding agent on a MacBook leaves a choice between an open lid and a bright screen on the kitchen table, or a closed lid and a run that ends when the machine falls asleep. Insomnia, a free menu bar app by a developer publishing as krishhgg, keeps the Mac awake only for the length of the session a user asks for. The MIT-licensed project has 468 stars on GitHub and sits at rank 8 on Trendshift's daily list on 10 October.
The app opens in the macOS menu bar and takes an end time in days, hours and minutes. The timer runs down and the session ends on its own. The README states that the timer keeps counting while the lid is closed, so a user can shut the MacBook, carry it to another room, and come back to a Mac that has gone to sleep rather than one that has been running on power for an extra eight hours.
What happens when the lid closes
Closing the lid during a session turns off the display and the keyboard backlight, pauses a configurable list of apps, saves and mutes the current audio output, and checks whether Docker is idle. The intent, from the README, is that a user can walk away from a running agent and not leave a bright screen on, without the agent itself being stopped by sleep.
Battery and thermal thresholds are also stated. Below 40 percent battery the app requests Low Power Mode. Below 10 percent it ends the session. A serious thermal state asks for Low Power Mode and a critical thermal state ends the session. These are rules the user does not have to write.
The recovery agent
A separate launchd agent runs at login and every 60 seconds. The README states that it attempts due recovery after an unexpected app exit, and that it leaves a valid, unexpired session unchanged. The design decision there is that if the Insomnia app itself crashes, the Mac does not get stuck awake until the user notices, and if the session was still valid, nothing is undone.
Insomnia is written in Swift. The README states that it needs macOS 26 or later on an Apple Silicon Mac, that the release builds are arm64 only, and that building from source needs Xcode and Swift 6.2 or later. Three installation routes are listed: a stable release from the GitHub releases page with a verification and installation script, nightly prerelease builds tagged by date and commit, and building from source. The repository shows 468 stars, 22 forks and 429 commits on main.
An unattended agent run that quietly uses eight hours of battery, or one that ends halfway through a long task, is a cost that an agent-using team already pays. The time limit and the recovery agent together are what a user would otherwise write by hand as a shell script and a caffeinate command, and they would not have the lid-close rules or the battery and thermal cut-offs.
Source
This item was written by an AI system from the linked source. Reveneau is responsible for what it publishes.
Get AI News in your inbox
New developer tools, model and agent releases, and how teams are actually using them to release software. Short, and only when there is something worth reading.