Skip to content
gadominasPublic

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

2 Commits

Folders and files

Repository files navigation

Insomnia

Insomnia is a small macOS menu bar app that keeps your Mac awake.

What it does

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.

How to use it (no technical skills needed)

  1. Get the app once — either download the ready-made Insomnia.app from this repository (see below), or ask a developer friend to run make install (a one-time step).
  2. Double-click Insomnia.app to open it.
  3. Click the Insomnia icon in the menu bar.
  4. Choose "Keep Awake (indefinite)" or one of the "Sleep After…" options.
  5. When you're done, click the icon again and choose "Stop".

That's it. Your Mac stays awake exactly as long as you want.

Downloading the ready-made app

The repository includes a prebuilt Insomnia.app folder. To get it:

  1. On GitHub, click the Code button and choose Download ZIP, or ask for the Insomnia.app folder from this repository.
  2. Unzip it (if you downloaded a ZIP) and move Insomnia.app to your Applications folder.
  3. 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.

For developers: how to build the app

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 app

After make build, commit the resulting Insomnia.app so non-technical users can download it from the repository.

Project layout

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.

How it works under the hood

  • 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 via SMAppService.
  • Logs are written to ~/Library/Logs/Insomnia/daemon.log.

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages