← all repositories
krishhgg/Insomnia

A menu-bar eye that keeps your MacBook awake while the lid is shut

Insomnia gives timed keep-awake sessions a safety net: journaled changes, a launchd recovery agent, and lid-close rules for people running coding agents on laptops.

★1.2k stars Swift Coding Assistants
Insomnia
Collecting fresh signals — velocity needs a few days of history.
collecting data…
star history

What it does

Insomnia is a SwiftUI menu bar app (no Dock icon, no window) that keeps a MacBook awake for a set duration — days, hours, minutes — and keeps the machine running with the lid closed. It’s aimed squarely at people letting coding agents like Claude Code or Codex run long sessions on a laptop. Closing the lid is optional; the timer counts down either way.

The interesting bit

The engineering care is in the failure paths. Every system change is written to a recovery journal on disk before it’s made, and a launchd backstop checks every minute to undo sessions whose app has crashed or quit. It also refuses to unfreeze a process it can’t prove it froze — a frozen app stays frozen until you inspect it, rather than being blindly resumed.

Key highlights

  • Lid close dims display and keyboard backlight (saving brightness first), freezes apps on a freeze list via SIGSTOP/SIGCONT (Slack, WhatsApp, Discord by default), mutes audio, and enables Low Power Mode — all undone on lid open.
  • Battery and heat rules: Low Power Mode below 40% battery, session ends below 10% or at critical heat; both configurable.
  • Optional extras: iPhone hotspot handoff when Wi-Fi drops, typing continue into tmux panes you’ve explicitly marked, and relaunching Chrome-family browsers unthrottled so background tabs don’t stall with the lid closed.
  • Honest about limits: the recovery agent can’t restore audio or watch battery/temperature, and the README warns that a running timer is not a safety guarantee for a closed bag.

Caveats

  • Requires macOS 26+ on Apple Silicon, and the project labels itself experimental.
  • The installer adds a sudoers rule at /etc/sudoers.d/insomnia allowing passwordless pmset calls — any program running as your user can use it, which the README itself flags for review.
  • Lid close hard-disables the built-in mic on Apple silicon/T2 laptops; recording needs AirPods or an external mic.

Verdict

Worth a look if you run long agent sessions on a MacBook and want lid-closed operation with actual recovery machinery instead of a bare caffeinate. Skip it if you’re on Intel, an older macOS, or uneasy about a sudoers entry — Amphetamine plus an external display may be the boring-but-sufficient answer.

Frequently asked

What is krishhgg/Insomnia?
Insomnia gives timed keep-awake sessions a safety net: journaled changes, a launchd recovery agent, and lid-close rules for people running coding agents on laptops.
Is Insomnia open source?
Yes — krishhgg/Insomnia is open source, released under the MIT license.
What language is Insomnia written in?
krishhgg/Insomnia is primarily written in Swift.
How popular is Insomnia?
krishhgg/Insomnia has 1.2k stars on GitHub.
Where can I find Insomnia?
krishhgg/Insomnia is on GitHub at https://github.com/krishhgg/Insomnia.

heatdrop uses Google Analytics to see which pages get read — nothing else. Your call. How we handle data.