Insomnia is a small macOS menu bar app that keeps your Mac awake.
When your Mac goes to sleep, background downloads, builds, and syncs are interrupted. Insomnia prevents that. It sits in the menu bar (the row of icons at the top right of your screen) and lets you:
- Keep Awake (indefinite) — the Mac will not sleep until you tell it to stop.
- Sleep After… — the Mac stays awake for a set time (1, 2, 5, 8, or 24 hours), then goes back to normal.
- Stop — ends the "keep awake" mode immediately.
- Launch at Login — optionally start Insomnia automatically every time you sign in.
The menu bar icon shows a moon when inactive and a sun when active. Hovering over it tells you how long the Mac will stay awake.
- Get the app once — either download the ready-made
Insomnia.appfrom this repository (see below), or ask a developer friend to runmake install(a one-time step). - Double-click
Insomnia.appto open it. - Click the Insomnia icon in the menu bar.
- Choose "Keep Awake (indefinite)" or one of the "Sleep After…" options.
- When you're done, click the icon again and choose "Stop".
That's it. Your Mac stays awake exactly as long as you want.
The repository includes a prebuilt Insomnia.app folder. To get it:
- On GitHub, click the Code button and choose Download ZIP, or ask for the
Insomnia.appfolder from this repository. - Unzip it (if you downloaded a ZIP) and move
Insomnia.appto your Applications folder. - Double-click it in Applications.
Note: macOS may warn that the app is from an unidentified developer. Right-click (or Control-click) the app, choose Open, and confirm once. If you built it yourself on your own Mac, no warning appears.
Requirements: a Mac with Xcode command line tools installed (xcode-select --install). No other dependencies — the app is two plain Swift files compiled with swiftc.
make build # compiles the app into Insomnia.app
make run # build + open the app
make install # build + copy to /Applications and launch
make clean # remove the built appAfter make build, commit the resulting Insomnia.app so non-technical users can download it from the repository.
| Path | Purpose |
|---|---|
Sources/Insomnia.swift |
Menu bar app (AppKit). Also acts as a CLI: Insomnia --status, --start, --stop, --timed <hours>, --login-on, --login-off. |
Sources/insomniad.swift |
Background daemon (insomniad) that holds the actual macOS power assertions (mirrors caffeinate -dimsu). |
Info.plist |
App bundle metadata. |
Makefile |
Build/install targets. |
Insomnia.app/ |
Prebuilt app bundle, committed for easy download. |
- The daemon creates IOKit power assertions (
PreventUserIdleSystemSleep,PreventUserIdleDisplaySleep,PreventDiskIdle,PreventSystemSleep,UserIsActive) and publishes its state to~/Library/Application Support/Insomnia/state.json. - The menu bar app reads that state file every 5 seconds to show status.
- "Launch at Login" installs a LaunchAgent (
~/Library/LaunchAgents/com.eis.insomnia.daemon.plist) and, on macOS 13+, registers the app viaSMAppService. - Logs are written to
~/Library/Logs/Insomnia/daemon.log.