The INSOMNIA guide · 28 Oct 2026
One line keeps your Mac awake with the lid shut
You commented INSOMNIA. Here's the line I use, what the Insomnia app adds on top of it, and how I run it.
1The line
My agents have run with the lid shut for over a year and a half. This is the line.
sudo pmset -a disablesleep 1
sudo asks for your password. Your Mac stops sleeping, lid open or shut.
This is the line that turns it back off:
sudo pmset -a disablesleep 0
The line has no timer, no battery limit and no heat limit. That part is on you.
2What Insomnia adds
Insomnia is an open-source menu bar app (MIT) by Krish Garg. Under the hood it runs the same line. Around it:
- An eye in your menu bar. Type days, hours and minutes, press Enter, and the session has an end time.
- Close the lid and the display and keyboard light go off.
- Slack, WhatsApp and Discord are paused. You can change that list.
- Sound is muted and Low Power Mode turns on.
- On battery, Low Power Mode comes on below 40% and the session ends below 10%. Those are the defaults. Heat rules are on too. These only work while the app is running.
- If the Wi-Fi drops, it can join your iPhone hotspot. You set that up in its Settings.
- When the session ends, it tries to undo what it changed, from a journal it writes as it goes.
It needs macOS 26 or later on an Apple Silicon Mac. Its own README calls it experimental.
To install, the README gives you one prompt to paste into your coding agent. The installer adds a sudoers rule. It lets your user, and any program running as you, run four pmset commands without a password. Read that part of the README before you install.
3How I run it
I close the lid, the laptop goes in my bag, and it rides my iPhone hotspot. The agents keep working while I walk.
4The links
- The repo: github.com/krishhgg/Insomnia
- The site: getinsomnia.app
