Skip to content

Anthemty/cafe

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cafe

License: MIT Rust macOS Made with objc2

A tiny macOS menu bar keep-awake tool for agent coding sessions.

Tired of your Mac dozing off while a long-running coding agent does its thing? cafe parks a coffee cup in your menu bar. Click it, pick a mode, and your Mac stays awake until you switch it off. The icon's color tells you the state at a glance — no more guessing whether caffeinate is still running.

Built in pure Rust on top of the system caffeinate, with no web view and no dependencies beyond macOS itself — just a ~400 KB binary that lives in your menu bar.


Features

  • Three modes (mutually exclusive, in the menu):
    Mode caffeinate flags Icon color Effect
    Off gray no sleep prevention
    Idle Only -i warm yellow prevents idle system sleep; display may dim
    Idle + Display -di deep orange prevents idle sleep and keeps the display on
  • Color-coded icon — the coffee cup (SF Symbol cup.and.saucer.fill) is tinted via a hierarchical symbol configuration, so the color is always visible and reliable across macOS versions (including macOS 26 / Tahoe).
  • No leaked processes. The caffeinate child is tracked and killed on every mode change and on quit/panic (Drop guarantee).
  • Starts off. Always launches in Off for safety — you opt in each time.
  • Remembers your last mode in ~/Library/Application Support/cafe/config.json (for UX continuity; it is not auto-applied on launch).
  • Menu bar only. Runs as an accessory — no Dock icon, no main window.

Requirements

  • macOS 11.0 (Big Sur) or newer
  • Rust 1.74+ (only needed to build from source)

Install

Option A — build the .app bundle (recommended)

git clone https://github.com/Anthemty/cafe.git
cd cafe
./make-app.sh          # produces dist/cafe.app
open dist/cafe.app

The first time you run it, macOS may show "cafe cannot be opened because the developer cannot be verified" (it's unsigned). To bypass: right-click the app → OpenOpen in the dialog. This one-time approval sticks.

Option B — run the raw binary

cargo build --release
./target/release/cafe

A coffee cup appears in the menu bar. Click it, pick a mode, and your Mac stays awake until you switch back to Off or Quit.

💡 The raw binary has no app icon; make-app.sh is the way to get the full experience (app icon, proper name in Force Quit, clean LSUIElement behavior).

How it works

cafe spawns and supervises a single caffeinate child process, restarting it with different flags when you switch modes:

mode change ──► Supervisor::enter(mode) ──► kill old child ──► spawn new child
                                                  │
                          (caffeinate flags from Mode::caffeinate_args)

The supervisor is pure Rust with no AppKit dependency and is fully unit-tested using sleep as a stand-in for caffeinate. The GUI layer is thin: an NSStatusItem + NSMenu whose actions call back into the supervisor.

Project layout

src/
  main.rs         NSApp setup, status item + menu, action callbacks (define_class!)
  supervisor.rs   caffeinate child-process lifecycle (spawn / kill / reap)
  state.rs        Mode enum + JSON persistence
  icon.rs         SF Symbol + per-mode hierarchical color
make-app.sh       Build the .app bundle and generate the app icon
resources/        Generated icon assets (AppIcon.icns)

Develop

cargo build         # debug build
cargo test          # run supervisor unit tests
cargo clippy        # lint
./make-app.sh       # full release .app

Why not just caffeinate -i &?

You can — but you'll forget it's running, leave for the night, and come back to a hot laptop with a dead battery. cafe makes the state visible (the icon color) and trivial to toggle off.

Roadmap

Possible future additions (not yet implemented):

  • Launch at login
  • Global hotkey to toggle modes
  • Auto-detect running agent processes (Claude Code, Cursor, …) and arm automatically
  • Timer mode ("keep awake for the next 2 hours")

Contributing

Contributions are welcome! Please open an issue first to discuss what you'd like to change. Run cargo fmt, cargo clippy, and cargo test before submitting.

License

This project is licensed under the MIT License.

Copyright © 2026 Anthemty.

About

☕ A tiny macOS menu bar keep-awake tool for agent coding sessions. Pure Rust, no web view, ~400KB.

Topics

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Packages

 
 
 

Contributors