Skip to content

callmepopo/CodexBarQuotaMenuBar

Repository files navigation

CodexBar Quota Menu Bar

中文说明在前,English follows below.

CodexBar Quota Menu Bar 是一个独立的 macOS 菜单栏额度查看工具,用来重新展示 CodexBar 已经生成在本机的额度数据。

它不是 CodexBar 官方插件,也不会修改 CodexBar 原程序。原版 CodexBar 仍负责登录、认证、额度刷新和本地数据生成;本工具只负责把这些本地展示数据用更适合日常查看的菜单栏 UI 展示出来,并增加 Codex 账号切换入口。

当前支持

  • Codex 账号额度显示。
  • Claude 账号额度显示。
  • 多个 Codex 账号列表展示。
  • Codex CLI 当前账号标记。
  • Codex CLI 账号切换:点击 Switch 后,把 CodexBar 托管账号的授权文件切换到当前 Codex CLI 使用的账号。
  • 邮箱脱敏展示。
  • 断网或 CodexBar 刷新失败时,优先显示 DIY 记录的最后一次成功额度快照。
  • 左键点击菜单栏图标打开额度面板,右键点击可刷新或退出。

下载和安装

请到 GitHub Releases 下载最新的安装包:

CodexBarQuotaMenuBar-macOS-arm64.zip

使用方式:

  1. 下载并解压 zip。
  2. 双击 CodexBarQuotaMenuBar.app 启动。
  3. 启动后不会出现在 Dock,只会显示在 macOS 菜单栏。
  4. 如果 macOS 首次提示无法验证开发者,请在 Finder 中右键 App,选择 打开,再确认打开。

当前安装包面向 Apple Silicon Mac,最低支持 macOS 13。

使用前提

使用前请先安装并运行原版 CodexBar。

建议顺序:

  1. 先启动原版 CodexBar,让它完成登录和额度刷新。
  2. 再启动 CodexBarQuotaMenuBar.app
  3. 日常只看 DIY 菜单栏图标即可。

如果原版 CodexBar 没有运行,本工具可能只能显示旧数据,或者显示暂无数据。

隐私和安全边界

本工具遵守以下边界:

  • 不修改 /Applications/CodexBar.app
  • 不修改 CodexBar 配置。
  • 不上传任何本地数据。
  • 额度百分比、Reset 时间和 Not started yet 判断只来自 CodexBar 本地额度数据。
  • 不明文输出、记录或展示 Token、id_token、refresh token、Cookie、OAuth secret、API Key。
  • 不使用 auth.json 推导额度百分比、Reset 时间或额度状态。
  • 展示邮箱时会脱敏。

本工具读取的本地额度展示数据包括:

~/Library/Group Containers/Y5PE65HELJ.com.steipete.codexbar/widget-snapshot.json
~/Library/Application Support/CodexBar/managed-codex-accounts.json
~/Library/Application Support/CodexBar/codex-account-snapshots.json
~/Library/Application Support/com.steipete.codexbar/history/codex.json
~/Library/Application Support/com.steipete.codexbar/history/claude.json

本工具还会维护一个自己的最后一次成功 Codex 快照缓存:

~/Library/Application Support/CodexBarQuotaMenuBar/last-good-codex-snapshots.json

该缓存只保存每个 Codex 账号最新一条成功额度快照,后续成功刷新会覆盖旧值,不会追加历史。缓存不保存完整邮箱、Token、Cookie、API Key 或授权文件内容。

为了判断当前 Codex CLI 使用中的账号、兜底识别邮箱和套餐类型,并支持账号切换,本工具会读取:

~/.codex/auth.json

Codex/CodexBar 授权配置只作为账号身份辅助来源,不作为额度来源。

点击 Switch 切换 Codex 账号时,本工具会:

  • 先备份当前 ~/.codex/auth.json~/.codex/auth-backups/
  • 再把 CodexBar 托管的目标账号授权文件复制为新的 ~/.codex/auth.json
  • 不会改动 CodexBar 原程序和 CodexBar 配置。

操作说明

  • 左键点击菜单栏图标:打开或关闭额度面板。
  • 右键点击菜单栏图标:显示 刷新退出
  • 面板右上角刷新按钮:立即重新读取本地额度数据。
  • 面板右上角 x:退出菜单栏工具。
  • Codex 账号右侧 Switch:切换当前 Codex CLI 账号。
  • Codex 账号右侧 Active:表示当前 Codex CLI 正在使用该账号。

验证方法

启动后可以检查:

  1. 菜单栏是否出现图标。
  2. 左键点击后是否弹出额度面板。
  3. Codex 和 Claude 账号是否正常显示。
  4. Codex 账号数量是否与 CodexBar 一致。
  5. 5 小时、1 周等额度百分比是否与 CodexBar 一致。
  6. 邮箱是否已经脱敏。
  7. 点击 Switch 后,重开终端运行 Codex CLI,是否切换到目标账号。

回退方式

如果不想继续使用:

  1. 右键点击菜单栏图标。
  2. 选择 退出
  3. 删除 CodexBarQuotaMenuBar.app

如果使用过 Switch 并想恢复之前的 Codex CLI 账号,可以从下面目录找回备份:

~/.codex/auth-backups/

本工具没有修改 CodexBar 原程序,不需要恢复 CodexBar。

从源码构建

需要 Xcode Command Line Tools。

swift build -c release

生成可下载 App 包:

./scripts/package_app.sh

打包结果在:

dist/CodexBarQuotaMenuBar-macOS-arm64.zip

CodexBar Quota Menu Bar

CodexBar Quota Menu Bar is an independent macOS menu bar app that presents local quota data already generated by CodexBar.

It is not an official CodexBar plugin and it does not modify the original CodexBar app. CodexBar still handles login, authentication, quota refresh, and local data generation. This app only provides a cleaner menu bar UI for daily quota checks and adds a Codex account switching shortcut.

Current Support

  • Display quota usage for Codex accounts.
  • Display quota usage for Claude accounts.
  • Show multiple Codex accounts.
  • Mark the currently active Codex CLI account.
  • Switch the active Codex CLI account by clicking Switch.
  • Mask email addresses in the UI.
  • Show the DIY last successful quota snapshot when offline or when CodexBar refresh fails.
  • Left-click the menu bar icon to open the quota panel; right-click to refresh or quit.

Download and Install

Download the latest package from GitHub Releases:

CodexBarQuotaMenuBar-macOS-arm64.zip

How to use:

  1. Download and unzip the package.
  2. Double-click CodexBarQuotaMenuBar.app.
  3. The app does not show a Dock icon. It only appears in the macOS menu bar.
  4. If macOS warns that the developer cannot be verified, right-click the app in Finder, choose Open, and confirm.

The current package targets Apple Silicon Macs and requires macOS 13 or later.

Requirements

Install and run the original CodexBar first.

Recommended order:

  1. Start CodexBar and let it refresh account quota data.
  2. Start CodexBarQuotaMenuBar.app.
  3. Use the DIY menu bar icon for daily checks.

If CodexBar is not running, this app may only show stale data or no data.

Privacy and Safety

This app follows these boundaries:

  • It does not modify /Applications/CodexBar.app.
  • It does not modify CodexBar settings.
  • It does not upload any local data.
  • Quota percentages, reset times, and Not started yet are derived only from CodexBar local quota data.
  • It does not print, log, or display tokens, id_token, refresh tokens, cookies, OAuth secrets, or API keys.
  • It does not use auth.json to infer quota percentages, reset times, or quota status.
  • Email addresses are masked in the UI.

The app reads these local quota display data files:

~/Library/Group Containers/Y5PE65HELJ.com.steipete.codexbar/widget-snapshot.json
~/Library/Application Support/CodexBar/managed-codex-accounts.json
~/Library/Application Support/CodexBar/codex-account-snapshots.json
~/Library/Application Support/com.steipete.codexbar/history/codex.json
~/Library/Application Support/com.steipete.codexbar/history/claude.json

The app also maintains its own last successful Codex snapshot cache:

~/Library/Application Support/CodexBarQuotaMenuBar/last-good-codex-snapshots.json

This cache stores only one latest successful quota snapshot per Codex account. Successful refreshes overwrite previous values instead of appending history. It does not store full email addresses, tokens, cookies, API keys, or auth file contents.

To detect the active Codex CLI account, use email and plan type as fallback identity metadata, and support account switching, the app reads:

~/.codex/auth.json

Codex/CodexBar auth configuration is used only as account identity metadata, not as a quota source.

When you click Switch, the app will:

  • Back up the current ~/.codex/auth.json to ~/.codex/auth-backups/.
  • Copy the selected CodexBar-managed account auth file to ~/.codex/auth.json.
  • Leave the original CodexBar app and CodexBar settings untouched.

Usage

  • Left-click the menu bar icon: open or close the quota panel.
  • Right-click the menu bar icon: show Refresh and Quit.
  • Refresh button in the panel: reload local quota data.
  • x button in the panel: quit the menu bar app.
  • Switch on a Codex account: switch the active Codex CLI account.
  • Active on a Codex account: indicates the account currently used by Codex CLI.

Verification

After launching, check:

  1. The menu bar icon appears.
  2. Left-click opens the quota panel.
  3. Codex and Claude accounts are displayed.
  4. The Codex account count matches CodexBar.
  5. Quota percentages, such as 5-hour and 1-week windows, match CodexBar.
  6. Email addresses are masked.
  7. After clicking Switch, restart your terminal and confirm Codex CLI uses the selected account.

Rollback

To stop using the app:

  1. Right-click the menu bar icon.
  2. Choose Quit.
  3. Delete CodexBarQuotaMenuBar.app.

If you used Switch and want to restore a previous Codex CLI account, check the backups in:

~/.codex/auth-backups/

This app does not modify the original CodexBar app, so there is nothing to restore in CodexBar.

Build from Source

Xcode Command Line Tools are required.

swift build -c release

Build a downloadable app package:

./scripts/package_app.sh

The package will be created at:

dist/CodexBarQuotaMenuBar-macOS-arm64.zip

About

A macOS menu bar quota viewer for CodexBar local Codex and Claude usage data

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors