A tiny macOS menu bar app that toggles pmset -a disablesleep — keep your Mac
awake with the lid closed, with one click.
- 🌙 moon.stars.fill = sleep disabled (Mac stays awake, even with the lid closed)
- 💤 moon.zzz = sleep allowed (normal macOS behavior); dimmed while on battery
- State is re-read from
pmset -gevery time the menu opens, so it never lies
- One-click toggle (
⌘T) — first use asks for the admin password once, then installs a narrowly-scoped sudoers rule (/etc/sudoers.d/insomnia) that allows exactlypmset -a disablesleep 1and0without a password. Every later toggle is instant and silent. - Auto-Sleep on Battery (on by default) — when unplugged, sleep is automatically re-enabled so your Mac doesn't drain in a bag; back on AC, insomnia resumes. Uses IOKit power-source notifications.
- Launch at Login (
⌘L) — viaSMAppService(macOS 13+). - No Dock icon, no window — pure menu bar (LSUIElement).
Requires macOS 12+ and Xcode Command Line Tools
(xcode-select --install if you don't have them).
curl -fsSL https://raw.githubusercontent.com/Panoplos/Insomnia/master/install-from-source.sh | bashThis clones the repo to a temp dir, builds Insomnia.app, installs it to
/Applications, and launches it. On first toggle you'll enter your password
once; after that everything is passwordless.
git clone https://github.com/Panoplos/Insomnia.git
cd Insomnia
./build.sh # builds Insomnia.app and runs self-checks
./install.sh # optional: installs to /Applicationscurl -fsSL https://raw.githubusercontent.com/Panoplos/Insomnia/master/uninstall.sh | bash(or run ./uninstall.sh from a clone). It removes the app, preferences, and
the sudoers rule; the password prompt appears only if the rule exists. If
"Launch at Login" was enabled, a dead entry may linger under
System Settings > Login Items — inert, delete it there manually.
Manual uninstall:
- Menu: uncheck Launch at Login, then Quit
- Remove the app:
rm -rf /Applications/Insomnia.app - Remove the sudoers rule:
sudo rm /etc/sudoers.d/insomnia - Reset preferences:
defaults delete local.makoto.Insomnia
- Read:
pmset -g→ parse theSleepDisabledline - Write:
sudo -n pmset -a disablesleep 1|0(passwordless via the sudoers rule; the rule is created through a one-time admin prompt and validated withvisudobefore it sticks) - Battery watch:
IOPSNotificationCreateRunLoopSourcefrom IOKit
Note: disablesleep is a single system-wide switch — it cannot be scoped to
"AC only" via pmset, which is why the battery handling lives in the app.
main.swift # the entire app (~170 lines)
build.sh # builds Insomnia.app, runs self-checks
install.sh # installs the built app to /Applications
install-from-source.sh # curl|bash bootstrap: clone + build + install
uninstall.sh # full removal: app, prefs, sudoers rule