macOS Daily Tracker
[Swift 6] Native macOS menu bar app · Converts screen time into real-time earnings/costs · Rule-based app & domain classifier · Local SQLite · Daily self-use
A native macOS menu bar app that turns active screen time into a running daily ledger — work minutes earn income, entertainment minutes accrue cost, and neutral or idle minutes are ignored. Built in Swift 6 with SwiftUI’s MenuBarExtra API, the app runs silently in the background, sampling context every 15 seconds and aggregating into minute-level records stored locally in SQLite. No cloud, no subscription, no tracking — just a live number in your menu bar that makes attention visible while you’re still spending it.
Private repository — not yet public. Feel free to reach out if you’d like to try it.
Highlights
- Built a priority-layered rule engine: idle detection → domain rules → user app rules → built-in defaults → neutral fallback; browser URL captured via AppleScript across 7 browsers (Safari, Chrome, Arc, Brave, Edge, Chromium, Safari TP)
- Designed subdomain-aware domain matching —
mail.google.combeatsgoogle.com; adding a rule for an existing host overwrites rather than duplicates, keeping the rule set consistent - Implemented SQLite persistence with schema migrations — minute records store bundle ID, app name, classification, decision source, amount in cents, and active/idle flag; schema versioning handles upgrades transparently
- Live menu bar summary: net earnings (green ▲ / yellow = / red ▼ / pause icon), earned vs. spent breakdown, and one-click rule creation for the current app or domain — all without opening a separate window
- Full 15s sampling loop with keyboard/mouse idle detection; aggregates samples into minute buckets, so the daily ledger is immune to brief focus switches
- Self-dogfooding: used daily as a personal productivity tool, driving continuous refinement of default rules and edge-case handling
How It Works
The core loop runs every 15 seconds:
- Context capture — reads frontmost app (bundle ID + name); if it’s a supported browser, fires AppleScript to get the current tab URL
- Rule engine — resolves classification in priority order: idle → domain rule → user app rule → built-in default → neutral
- Aggregation — winning classification accumulates into the current minute bucket in SQLite
- Ledger update — today’s net, earned, and spent totals recompute live; menu bar icon and label refresh immediately
Screenshots
Technical Summary
| Language | Swift 6 |
| UI | SwiftUI, MenuBarExtra (macOS 13+ API) |
| Storage | SQLite (local, ~/Library/Application Support/) |
| Classification | Rule-based engine: idle → domain → app → default → neutral |
| Browser integration | AppleScript URL capture (7 browsers) |
| Sampling | 15-second context poll → minute-level aggregation |
| Platform | macOS 14+ |
| Build | Xcode / xcodebuild, Swift Package Manager |