App Receipt
Track macOS app usage and auto-roll into thermal-receipt-style HTML/PNG reports.
Preview
Daily HTML/PNG receipts. Dotted separators, ★ brand, bilingual easter-egg footer, Code 128 barcode, red stamp — styled like real thermal paper. Web UI on :7878 with form + live preview + PNG download.
Install
Requires macOS + Node.js 18+. One-liner installs LaunchAgent + tracker + web UI:
curl -sL https://github.com/linweiheng2009-ops/app-receipt/raw/main/install.sh | bash
Usage
- Tracker samples the frontmost app every 10s; data lands in
~/app-receipts/<YYYY-MM-DD>.json - CLI:
node ~/app-receipt/scripts/app-receipt.mjs todayemits today's HTML receipt - Web UI:
node ~/app-receipt/scripts/app-receipt-web.mjs→ openhttp://localhost:7878 - Bilingual (EN/中文), event tracking (app switches, screen locks, wake count)
- Uninstall:
~/app-receipt/uninstall.sh(--purgedeletes data;--keep-repokeeps repo)
Stack
- NSWorkspace.frontmostApplication — 前台 app 检测(无需 TCC 权限)
- ioreg HIDIdleTime — 闲置秒数检测
- LaunchAgent (StartInterval=10) — 后台常驻,无需手动启动
- Node.js + 自包含 HTML 模板 — 收据渲染
- Playwright + 系统 Chrome — PNG 导出 1080×1350 retina
- JSONL 原子写(tmp + rename)— 防半写状态
Data format
One JSON per day with fields date / apps / totalSec / idleSec / startedAt / lastUpdated / events. Plain cat-readable; trivial to back up.