Skip to content

About

Open-source macOS menu-bar utility with timers, hotkeys, battery protection, and automatic updates.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

50 stars

Watchers

0 watching

Forks

Repository files navigation

Open Caffeine

An open-source macOS menu-bar utility that keeps your Mac awake for a chosen duration. Built for Apple Silicon and macOS 26 (Tahoe) or newer with a native Liquid Glass UI.

Open Caffeine - Keep your Mac awake | Product Hunt

🏆 Ranked #10 Product of the Day on Product Hunt

Features

  • Timed sessions from 5 minutes to 8 hours, plus a keep-awake-forever mode
  • Separate control over display sleep and system sleep
  • Live menu-bar countdown and a customizable global shortcut
  • Optional battery threshold that stops an active session
  • Launch-at-login, Dock visibility, appearance, and menu-bar icon preferences
  • EdDSA-verified automatic updates through Sparkle

Install

Download the latest archive from GitHub Releases, extract it, and move Open Caffeine.app to /Applications.

Open Caffeine releases are EdDSA-signed for Sparkle update integrity, but the app is not Apple code-signed or notarized. On first launch, macOS may require System Settings → Privacy & Security → Open Anyway.

Build from source

Prerequisites:

brew install xcodegen swiftlint

Generate and build:

xcodegen generate
xcodebuild -project OpenCaffeine.xcodeproj -scheme OpenCaffeine -configuration Release build

The app bundle is in ~/Library/Developer/Xcode/DerivedData/OpenCaffeine-*/Build/Products/Release/Open Caffeine.app.

Releasing updates (Sparkle)

Auto-updates use Sparkle. SUFeedURL points at appcast.xml in this repo (served via raw.githubusercontent.com), and updates are EdDSA-signed with the private key in your login keychain (public key is in Info.plist as SUPublicEDKey).

To cut a release:

  1. Bump MARKETING_VERSION / CURRENT_PROJECT_VERSION in project.yml.
  2. Run Scripts/release.sh — builds Release, zips, EdDSA-signs, and regenerates appcast.xml.
  3. Create a GitHub release tagged v<version> and upload dist/Open-Caffeine-<version>.zip.
  4. Commit & push appcast.xml.

The Updates preferences tab ("Check Now" + automatic checks) drives the real Sparkle updater against that feed.

Run tests

xcodebuild -project OpenCaffeine.xcodeproj -scheme OpenCaffeine -destination 'platform=macOS' test

Coverage

Every logic file must keep 100% line coverage. The gate runs the suite with coverage and fails if any non-excluded file under OpenCaffeine/ drops below 100%:

Scripts/coverage-gate.sh

It is enforced on git push via a pre-push hook. Enable it once per clone:

git config core.hooksPath Scripts/hooks

Bypass a single push with git push --no-verify.

What's excluded and why. Only UI/AppKit/system shells are exempt — SwiftUI view bodies, the @main entry, AppDelegate/MenuBarController wiring, NSAlert/NSWindow presenters, and thin IOKit/SMAppService/KeyboardShortcuts/NSWorkspace adapters. Their decision logic has been extracted into separately-tested types (GeneralSettingsActions, BatteryThresholdFormatter, MenuBarIconModel, CustomDurationParser, AppLaunchLogic, BatterySnapshotParser, the *Providing/*Controlling seams). The full, justified list lives in Scripts/coverage_check.py — new source files are not exempt by default, so adding one forces a conscious choice: test it, or extract its logic and list the shell.

Manual QA Checklist

  • Start for 5 min → countdown begins at 5:00 next to icon.
  • After 5 min, icon reverts and sleep works again.
  • Forever → still awake after 30 min idle.
  • Forever + "Keep the screen on" ON (default) → screen stays on past the display-sleep timer.
  • "Keep the screen on" OFF → display may sleep, but the Mac stays awake.
  • Toggling "Keep the screen on" during an active session takes effect immediately.
  • Hotkey toggles caffeine on/off.
  • Start-at-login toggle survives reboot.
  • Show-in-dock toggle takes effect immediately.
  • Battery threshold triggers stop (use pmset if hard to drain).
  • pmset -g assertions shows PreventUserIdleDisplaySleep while active (or …SystemSleep when "Keep the screen on" is off).
  • About menu shows custom Open Caffeine panel.
  • Screensaver launches from menu.
  • Custom duration prompt accepts minutes input.
  • Switching Appearance in Preferences changes the menubar icon immediately.

Project layout

OpenCaffeine/
  App/                 # @main, AppDelegate (bootstrap)
  MenuBar/             # NSStatusItem controller, menu builder, countdown formatter, custom-duration prompt
  Services/            # SleepAssertion, CaffeineSession, HotKeyService, BatteryMonitor, LoginItemManager, ScreenSaverLauncher
  Settings/            # SwiftUI Preferences scene + tabs
  Models/              # CaffeineDuration, SessionState, MenuBarIconStyle
  Resources/           # Assets.xcassets, About panel
OpenCaffeineTests/      # XCTest suites + Mocks/
docs/superpowers/      # Spec + plan that drove this build
project.yml            # XcodeGen project definition (single source of truth — .xcodeproj is regenerated, not committed)
.swiftlint.yml         # Lint config (file_length 500 hard cap)

Architecture

See docs/superpowers/specs/2026-05-28-open-caffeine-design.md.

License

MIT © Open Caffeine contributors.

About

Open-source macOS menu-bar utility with timers, hotkeys, battery protection, and automatic updates.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

50 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages