{"id":51509070,"url":"https://github.com/acehubert/codextouchbarquota","last_synced_at":"2026-07-08T04:01:00.631Z","repository":{"id":364241472,"uuid":"1267023545","full_name":"aceHubert/CodexTouchBarQuota","owner":"aceHubert","description":"一个 Swift/AppKit macOS 菜单栏 + Touch Bar 小应用，用本机 Codex app-server 读取 `account/rateLimits/read`，不抓网页。","archived":false,"fork":false,"pushed_at":"2026-06-23T08:00:55.000Z","size":2784,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-06-23T09:25:36.508Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/aceHubert.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-06-12T06:43:02.000Z","updated_at":"2026-06-23T08:01:06.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/aceHubert/CodexTouchBarQuota","commit_stats":null,"previous_names":["acehubert/codextouchbarquota"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/aceHubert/CodexTouchBarQuota","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aceHubert%2FCodexTouchBarQuota","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aceHubert%2FCodexTouchBarQuota/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aceHubert%2FCodexTouchBarQuota/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aceHubert%2FCodexTouchBarQuota/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aceHubert","download_url":"https://codeload.github.com/aceHubert/CodexTouchBarQuota/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aceHubert%2FCodexTouchBarQuota/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":35251017,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-07-08T02:00:06.796Z","response_time":61,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-07-08T04:00:59.761Z","updated_at":"2026-07-08T04:01:00.620Z","avatar_url":"https://github.com/aceHubert.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CodexTouchBarQuota\n\n一个 Swift/AppKit macOS 菜单栏 + Touch Bar 小应用，用本机 Codex app-server 读取 `account/rateLimits/read`，不抓网页。\n\n## 功能\n\n- 启动本机 Codex：`/Applications/Codex.app/Contents/Resources/codex app-server --listen stdio://`\n- 通过 JSONL / JSON-RPC 调用：`initialize` → `initialized` → `account/rateLimits/read`\n- 显示两行额度，窗口标题按时长自动识别：小时级（如 `5小时`）、`周限额`、`月限额`（free 账号）或 `N天`\n- 剩余额度按 `100 - usedPercent` 计算\n- 刷新时保留旧 UI，只有新数据成功返回后才替换旧数据\n- 读取失败时不清空旧数据，只在菜单窗口中显示错误\n- 成功数据会缓存到本地，应用重启或读取超时后仍显示最后一次额度和更新时间\n- 菜单栏常驻，点击菜单栏图标可展开同款额度面板\n- Touch Bar 主动提醒：低额度、快重置时在最前面显示 `🚨` / `⚠️` / `⏳`\n- 主动提醒优先走系统模态 Touch Bar（运行时检测 `presentSystemModalTouchBar` 私有 API），其他 App 在前台时也能弹出，显示 12 秒后自动消失；私有 API 不可用时回退到激活菜单栏弹窗\n- Touch Bar 使用固定 10 段电量条，普通状态和提醒状态宽度一致\n- 提醒面板支持“不再提醒”，会静默当前 5 小时或周限额周期\n- 菜单面板可设置主动提醒开关、低额度阈值（50–10%）、快重置时间（50–10 分钟）和再次提醒冷却时间（5–60 分钟）\n- 菜单面板提供“恢复提醒”按钮（仅在有静默或冷却状态时显示），可撤销“不再提醒”并清除冷却状态；另有“恢复默认”按钮一键还原默认提醒设置\n- 自动识别 Touch Bar 硬件：无 Touch Bar 的 Mac 上只显示菜单栏额度面板，隐藏提醒设置且不触发 Touch Bar 提醒\n\n## 构建\n\n```bash\ncd CodexTouchBarQuota\nmake app\nopen .build/release/CodexTouchBarQuota.app\n```\n\n安装到 `/Applications`：\n\n```bash\nmake install\nopen /Applications/CodexTouchBarQuota.app\n```\n\n## Touch Bar 显示条件\n\n这是公开 AppKit Touch Bar 实现。macOS 通常只会给当前激活 App 显示 Touch Bar 控件，所以点击菜单栏上的 `Codex` 状态项、让弹窗处于激活状态时，会显示两行额度条。\n\n如果 Touch Bar 没出现，检查：\n\n- 系统设置 → 键盘 → Touch Bar 显示内容：选择“App 控件”或包含 App 控件的模式\n- 机器需要是带 Touch Bar 的 MacBook Pro\n- Codex 需要已登录 ChatGPT 账号，否则 app-server 可能返回空或认证错误\n\n## 可调整参数\n\n在 `Sources/CodexTouchBarQuota/main.swift` 中：\n\n- `CodexRateLimitClient.codexExecutablePath`：Codex 可执行文件路径\n- `RateLimitStore.refreshInterval`：自动刷新间隔，默认 5 分钟；手动刷新按钮有 60 秒防重保护\n- `CodexRateLimitClient.requestTimeout`：单次 RPC 超时，默认 30 秒（rateLimits 读取走网络，延迟波动大）\n- `TouchBarAlertPresenter.displayDuration`：主动弹出 Touch Bar 的显示时长，默认 12 秒\n- 菜单面板“提醒设置”：主动提醒开关、低额度阈值、快重置时间、再次提醒间隔、恢复提醒（条件显示）、恢复默认\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Facehubert%2Fcodextouchbarquota","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Facehubert%2Fcodextouchbarquota","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Facehubert%2Fcodextouchbarquota/lists"}