Skip to content

Commit 4e0895a

Browse files
authored
docs: make setup guidance agent-neutral (aqua5230#16)
Reframes setup guidance so Codex-only users aren't treated as edge cases. Setup button gate changed from Claude-only directory check to status-line target availability (~/.claude/ or ~/.codex/config.toml). Fills missing ja/ko hook_not_installed translations and brings both README variants in sync. Co-authored-by: ericweichun <ericweichun@users.noreply.github.com>
1 parent 6c300d1 commit 4e0895a

5 files changed

Lines changed: 91 additions & 41 deletions

File tree

README.en.md

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ If Codex isn't installed or the directory doesn't exist, that part of the UI hid
7272

7373
- macOS
7474
- Python 3.13
75-
- Claude Code installed and signed in (Codex is optional)
75+
- Claude Code or Codex has been used at least once so local usage data exists
7676

7777
## Quick start
7878

@@ -104,11 +104,13 @@ Go to the [GitHub Releases page](https://github.com/aqua5230/usage/releases/late
104104
⚠️ Because this app is not signed with an Apple Developer certificate, **macOS Gatekeeper will block the first launch**.
105105
To open it: find `usage.app` in Finder → right-click → Open → confirm Open. After that, double-clicking works normally.
106106

107-
### First launch: install the hook
107+
### First launch: set up the status line
108108

109-
The first time you open usage, if Claude Code has never been wired up yet, the popover will detect the missing status file and **show an extra "Install hook now" button at the bottom**. Click it once — it installs the hook for you. Then **fully quit Claude Code (Cmd+Q) and re-open it**, click "Refresh now" in usage, and the numbers will appear.
109+
The first time you open usage, if you have already used Codex, the Codex card usually reads `~/.codex/sessions` and shows data directly. If you use Claude Code, the popover may show a **"Set Up Status Line"** button when app-side setup is needed. If you run from source and want to add Codex status-line fields, run the command below to configure detected agents.
110110

111-
If the button doesn't show, usage is already reading data (e.g. you previously installed the third-party tool [stormzhang/token-tracker](https://github.com/stormzhang/token-tracker) and its status file works as a fallback) — nothing else to do.
111+
Restart the relevant tool afterward: restart Codex once; if Claude Code was configured too, fully quit Claude Code (Cmd+Q) and re-open it.
112+
113+
If the button does not show, usage can already read data or there is no Claude Code setup action for the app to perform.
112114

113115
> **Fallback: install via curl**
114116
> If the in-app button doesn't work or you prefer the command line, run the following in Terminal (download first, inspect, then run):
@@ -119,7 +121,7 @@ If the button doesn't show, usage is already reading data (e.g. you previously i
119121
> bash /tmp/usage-install.sh
120122
> ```
121123
122-
After the hook is installed and Claude Code is restarted, the bottom of the Claude Code window will show a statusLine like this — **5h / 7d quota bars, context usage, session duration, current model — all on one line**. Percentages share the bar color (yellow / green / red), so the warning level reads at a glance:
124+
After the Claude Code hook is configured and Claude Code is restarted, the bottom of the Claude Code window will show a statusLine like this — **5h / 7d quota bars, context usage, session duration, current model — all on one line**. Percentages share the bar color (yellow / green / red), so the warning level reads at a glance:
123125
124126
<p align="center">
125127
<img src="docs/statusline.en.png" alt="Claude Code statusLine display (English)" width="640">
@@ -146,32 +148,33 @@ pip install -e .
146148
147149
This creates an isolated Python environment (`.venv`) for the project, activates it, and installs usage plus its dependencies into it.
148150
149-
## First install (wire up the Claude Code hook — source mode only)
151+
## Set up detected agents (source mode)
150152
151-
> Using the .app? Just click the "Install hook now" button in the popover on first launch instead — you don't need this section. The steps below are for developers running usage from source.
153+
> Using the .app? Click the "Set Up Status Line" button in the popover on first launch instead. The steps below are for developers running usage from source.
152154
153-
This single command does two things: copies the hook script into `~/.claude/`, and updates your Claude Code settings to point at it.
155+
This command configures detected agents: Codex gets `tui.status_line` in `~/.codex/config.toml`; if Claude Code is present, usage also copies the hook script into `~/.claude/` and updates Claude Code settings to point at it.
154156
155157
```bash
156158
source .venv/bin/activate
157159
python3 main.py --setup
158160
```
159161
160-
**Restart Claude Code once after running this** so it re-reads `~/.claude/settings.json` and refreshes its status line. That refresh is when usage data first lands on disk.
162+
**Restart Codex once after running this**. If Claude Code was configured, restart Claude Code too so it re-reads `~/.claude/settings.json` and refreshes its status line.
161163
162164
What `--setup` does in detail:
163165
164-
- Copies `usage_statusline.py` to `~/.claude/usage-statusline.py`.
165-
- Points `statusLine` in `~/.claude/settings.json` at that hook.
166-
- If you already had a custom `statusLine`, it is backed up to `settings.usage.previousStatusLine` so nothing is overwritten.
166+
- Configures `tui.status_line` in `~/.codex/config.toml` when Codex is detected.
167+
- If Claude Code is present, copies `usage_statusline.py` to `~/.claude/usage-statusline.py`.
168+
- If Claude Code is present, points `statusLine` in `~/.claude/settings.json` at that hook.
169+
- If you already had a custom Claude Code `statusLine`, it is backed up to `settings.usage.previousStatusLine` so nothing is overwritten.
167170
168171
To uninstall:
169172
170173
```bash
171174
python3 main.py --unsetup
172175
```
173176
174-
`--unsetup` restores your original statusLine and removes the hook and `~/.claude/usage-status.json`.
177+
`--unsetup` restores the original Codex `status_line` and Claude Code `statusLine`, then removes the Claude hook and `~/.claude/usage-status.json`.
175178
176179
## Run modes
177180
@@ -298,7 +301,7 @@ python3 main.py --tui --mock
298301
299302
## Options
300303
301-
- `--setup` / `--unsetup`install or remove the Claude Code statusLine hook.
304+
- `--setup` / `--unsetup` — configure or restore detected agents (Codex `status_line`; Claude Code `statusLine` hook).
302305
- `--tui` — force terminal TUI mode (no menu bar).
303306
- `--interval N` — how often (seconds) the UI re-reads the status file. Minimum 30, default 60.
304307
- `--mock` — use fake data; don't read any status file.
@@ -349,7 +352,7 @@ The "Fix" column distinguishes three kinds of users — find yours first:
349352
350353
| Symptom | Likely cause | Fix |
351354
|---------|--------------|-----|
352-
| Menu bar shows `--` | Hook not installed, or Claude Code hasn't refreshed yet | **.app users**: click the "Install hook now" button in the popover. **Source users**: run `python3 main.py --setup`. Either way, restart Claude Code once afterwards |
355+
| Menu bar shows `--` | No Codex `rate_limits` yet, or the Claude Code hook has not refreshed | Run one Codex conversation first. For Claude Code integration, **.app users** click "Set Up Status Line"; **Source users** run `python3 main.py --setup` |
353356
| Accidentally hit "Quit", paw icon disappeared from the menu bar | "Quit" fully terminates the usage process; you have to relaunch it | **.app users**: press `Cmd+Space` for Spotlight, type `usage`, hit Enter; or double-click `usage.app` from `/Applications`. **LaunchAgent users**: run `launchctl start com.lollapalooza.usage` in Terminal. **Source users**: run `python3 main.py` in Terminal again |
354357
| Status says "N minutes stale" | Claude Code isn't running | Open Claude Code and let it run; it updates the file on its next status refresh |
355358
| Codex section is empty | `~/.codex/sessions/` doesn't exist or has no `rate_limits` events yet | Run a Codex conversation to generate log entries |

README.md

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ Codex CLI 沒有 statusLine hook 這種機制,所以 usage 採另一條路:
7272

7373
- macOS
7474
- Python 3.13
75-
- 已經裝好、登入過 Claude CodeCodex 是可選的)
75+
- 已經使用過 Claude CodeCodex 其中之一,讓它們在本機留下用量資料
7676

7777
## 快速開始
7878

@@ -104,11 +104,13 @@ ln -s $(brew --prefix)/Cellar/usage/$(brew list --versions usage | awk '{print $
104104
⚠️ 因為沒有 Apple Developer 簽章,**第一次開啟時 macOS Gatekeeper(系統的「擋陌生程式」保全機制)會擋下來**
105105
解法:在 Finder 找到 `usage.app` → 按住 Ctrl 點右鍵 → 選「打開」→ 再確認一次「打開」。之後就能直接雙擊。
106106

107-
### 首次打開:把 hook 裝起來
107+
### 首次打開:設定狀態列
108108

109-
第一次打開 usage,如果你還沒「對接」過 Claude Code,popover 會偵測到「找不到狀態檔」,**最下面會多出一顆「立即安裝 hook」按鈕**,按一下就會幫你裝好。然後**完全結束 Claude Code(Cmd+Q)再重新打開一次**,在 usage 視窗按「立即更新」,數字就會跑出來
109+
第一次打開 usage,如果你已經用 Codex 跑過對話,Codex 區塊通常會直接讀取 `~/.codex/sessions` 並顯示。若你使用 Claude Code,popover 可能會在需要時顯示「設定狀態列」按鈕。若你是從原始碼執行、想補齊 Codex 狀態列欄位,可以用下方指令手動設定可偵測到的 agent
110110

111-
如果按鈕沒出現(代表 usage 已經抓到資料了,例如你之前裝過第三方工具 [stormzhang/token-tracker](https://github.com/stormzhang/token-tracker)),就什麼都不用做。
111+
設定後請重開相關工具:Codex 需要重新開啟一次;如果有設定 Claude Code,也請完全結束 Claude Code(Cmd+Q)再重新打開一次。
112+
113+
如果按鈕沒出現,代表 usage 已經能讀到資料,或目前沒有需要 app 介入的 Claude Code 設定。
112114

113115
> **備援:手動 curl 安裝**
114116
> 若按鈕按了沒反應、或你想用指令模式裝,打開 Terminal(終端機)執行以下指令(先下載、確認內容後再執行,比較安全):
@@ -119,7 +121,7 @@ ln -s $(brew --prefix)/Cellar/usage/$(brew list --versions usage | awk '{print $
119121
> bash /tmp/usage-install.sh
120122
> ```
121123
122-
裝完 hook 重啟 Claude Code 後,視窗底部會看到這樣的 statusLine —— **5 小時 / 7 天配額條、對話窗用量、會話時長、目前模型,全擠在一行**;數字跟進度條同色(黃 / 綠 / 紅),掃一眼就知道警示級別:
124+
設定 Claude Code hook 並重啟 Claude Code 後,視窗底部會看到這樣的 statusLine —— **5 小時 / 7 天配額條、對話窗用量、會話時長、目前模型,全擠在一行**;數字跟進度條同色(黃 / 綠 / 紅),掃一眼就知道警示級別:
123125
124126
<p align="center">
125127
<img src="docs/statusline.png" alt="Claude Code statusLine 顯示樣式(繁中)" width="640">
@@ -148,32 +150,33 @@ pip install -e .
148150

149151
`source .venv/bin/activate` 是「進入這個抽屜」的意思 —— 跑完之後你 terminal 提示字元前面會多一個 `(.venv)`,代表現在 Python 指令會在這個獨立環境裡跑。
150152

151-
## 跟 Claude Code 對接(原始碼模式必跑一次
153+
## 設定可偵測到的 agent(原始碼模式
152154

153-
> 用 .app 的話,第一次打開直接點 popover 上的「立即安裝 hook」按鈕就好,不用跑這段。下面是給從原始碼跑 usage 的開發者用的。
155+
> 用 .app 的話,第一次打開直接點 popover 上的「設定狀態列」按鈕即可。下面是給從原始碼跑 usage 的開發者用的。
154156
155-
這個指令會做兩件事:把 usage 的 hook 腳本複製到 `~/.claude/` 裡,再去改 Claude Code 的設定檔,讓它每次刷新狀態列時去叫這個 hook。
157+
這個指令會設定目前偵測到的 agent:Codex 會更新 `~/.codex/config.toml``tui.status_line`;如果你也有 Claude Code,會把 usage 的 hook 腳本複製到 `~/.claude/` 裡,再去改 Claude Code 的設定檔,讓它每次刷新狀態列時去叫這個 hook。
156158

157159
```bash
158160
source .venv/bin/activate
159161
python3 main.py --setup
160162
```
161163

162-
**跑完後請重開一次 Claude Code**,這樣它才會重新讀 `~/.claude/settings.json` 並刷新一次狀態列(資料這時候才會落到磁碟)。
164+
**跑完後請重開一次 Codex**。如果有設定 Claude Code,也請重開一次 Claude Code,這樣它才會重新讀 `~/.claude/settings.json` 並刷新一次狀態列(資料這時候才會落到磁碟)。
163165

164166
setup 具體做了什麼:
165167

166-
-`usage_statusline.py` 複製到 `~/.claude/usage-statusline.py`
167-
-`~/.claude/settings.json``statusLine` 指向這個 hook
168-
- 如果你本來就有自訂的 statusLine,會自動備份到 `settings.usage.previousStatusLine`,不會被蓋掉
168+
- 如果有 Codex,在 `~/.codex/config.toml` 設定 `tui.status_line`
169+
- 如果有 Claude Code,把 `usage_statusline.py` 複製到 `~/.claude/usage-statusline.py`
170+
- 如果有 Claude Code,在 `~/.claude/settings.json``statusLine` 指向這個 hook
171+
- 如果你本來就有自訂的 Claude Code statusLine,會自動備份到 `settings.usage.previousStatusLine`,不會被蓋掉
169172

170173
要卸載:
171174

172175
```bash
173176
python3 main.py --unsetup
174177
```
175178

176-
unsetup 會把原本的 statusLine 還原回去、刪掉 hook 跟 `~/.claude/usage-status.json`
179+
unsetup 會把原本的 Codex `status_line` 與 Claude Code `statusLine` 還原回去,並刪掉 Claude hook 跟 `~/.claude/usage-status.json`
177180

178181
## 跑起來
179182

@@ -300,7 +303,7 @@ python3 main.py --tui --mock
300303

301304
## 全部可用參數
302305

303-
- `--setup` / `--unsetup`安裝 / 卸載 Claude Code statusLine hook。
306+
- `--setup` / `--unsetup`設定 / 還原偵測到的 agent(Codex `status_line`Claude Code `statusLine` hook
304307
- `--tui`:強制使用終端機 TUI 模式(不開 menu bar)。
305308
- `--interval N`:UI 多久重新讀一次狀態檔(秒)。最小值 30,預設 60。
306309
- `--mock`:用假資料跑,不讀任何狀態檔。
@@ -351,7 +354,7 @@ USAGE_LANG=zh-CN python3 main.py # 簡體中文
351354

352355
| 症狀 | 原因 | 解法 |
353356
|------|------|------|
354-
| menu bar 顯示 `--` | hook 還沒裝、或 Claude Code 還沒刷新 | **.app 使用者**:點彈出視窗內的「立即安裝 hook」按鈕;**原始碼使用者**`python3 main.py --setup`。裝完都要重開一次 Claude Code |
357+
| menu bar 顯示 `--` | 還沒有 Codex rate_limits,或 Claude Code hook 還沒刷新 | 先用 Codex 跑一次對話;若要接 Claude Code,**.app 使用者**點「設定狀態列」,**原始碼使用者**`python3 main.py --setup` |
355358
| 不小心按「結束」、腳印從選單列消失 | 「結束」會把整個 usage 程式關掉,要手動再開 | **.app 使用者**:按 `Cmd+Space` 叫出 Spotlight、輸入 `usage` 雙擊;或從 `/Applications` 找到 `usage.app` 雙擊。**LaunchAgent 使用者**:在 Terminal 跑 `launchctl start com.lollapalooza.usage`**從原始碼跑的**:在 Terminal 再跑一次 `python3 main.py` |
356359
| 狀態顯示「N 分鐘未更新」 | Claude Code 沒在跑,沒有刷新 statusLine | 打開 Claude Code 跑一下,它刷新時會自動更新 |
357360
| Codex 那塊空白或不顯示 | `~/.codex/sessions/` 不存在,或還沒有含 rate_limits 的 token_count 事件 | 用 Codex 跑一次對話,等它寫入紀錄 |

i18n.json

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
"refresh_now": "↻ 立即更新",
6868
"analyze_usage": "報告",
6969
"analysis_failed": "分析報告產生失敗",
70-
"install_hook": "安裝 Hook",
70+
"install_hook": "設定狀態列",
7171
"quit": "⏻ 結束",
7272
"usage_title": "Usage",
7373
"current_label": "目前",
@@ -89,7 +89,7 @@
8989
"loading": "加载数据...",
9090
"no_data": "暂无数据",
9191
"no_agent": "未检测到任何 AI Agent",
92-
"hook_not_installed": "Hook 尚未安裝。請執行:usage setup",
92+
"hook_not_installed": "狀態列尚未設定。請執行:usage setup",
9393
"detected": "检测到: {agents}",
9494
"agent_not_found": "未检测到 {name}",
9595
"unknown_cmd": "未知命令: {cmd}",
@@ -320,7 +320,7 @@
320320
"refresh_now": "↻ Refresh Now",
321321
"analyze_usage": "Report",
322322
"analysis_failed": "Analysis report failed",
323-
"install_hook": "Install Hook",
323+
"install_hook": "Set Up Status Line",
324324
"quit": "⏻ Quit",
325325
"usage_title": "Usage",
326326
"current_label": "Current",
@@ -342,7 +342,7 @@
342342
"loading": "Loading...",
343343
"no_data": "No data",
344344
"no_agent": "No AI Agent detected",
345-
"hook_not_installed": "Hook not installed. Run: usage setup",
345+
"hook_not_installed": "Status line not configured. Run: usage setup",
346346
"detected": "Detected: {agents}",
347347
"agent_not_found": "{name} not detected",
348348
"unknown_cmd": "Unknown command: {cmd}",
@@ -573,7 +573,7 @@
573573
"refresh_now": "↻ 立即更新",
574574
"analyze_usage": "报告",
575575
"analysis_failed": "分析报告生成失败",
576-
"install_hook": "安装 Hook",
576+
"install_hook": "设置状态栏",
577577
"quit": "⏻ 结束",
578578
"usage_title": "Usage",
579579
"current_label": "当前",
@@ -595,7 +595,7 @@
595595
"loading": "加载数据...",
596596
"no_data": "暂无数据",
597597
"no_agent": "未检测到任何 AI Agent",
598-
"hook_not_installed": "Hook 尚未安装。请运行:usage setup",
598+
"hook_not_installed": "状态栏尚未设置。请运行:usage setup",
599599
"detected": "检测到: {agents}",
600600
"agent_not_found": "未检测到 {name}",
601601
"unknown_cmd": "未知命令: {cmd}",
@@ -826,7 +826,7 @@
826826
"refresh_now": "↻ 今すぐ更新",
827827
"analyze_usage": "レポート",
828828
"analysis_failed": "分析レポートの生成に失敗しました",
829-
"install_hook": "フックをインストール",
829+
"install_hook": "ステータスラインを設定",
830830
"quit": "⏻ 終了",
831831
"usage_title": "使用量",
832832
"current_label": "現在",
@@ -848,7 +848,7 @@
848848
"loading": "",
849849
"no_data": "",
850850
"no_agent": "",
851-
"hook_not_installed": "",
851+
"hook_not_installed": "ステータスラインが未設定です。実行してください: usage setup",
852852
"detected": "",
853853
"agent_not_found": "",
854854
"unknown_cmd": "",
@@ -1079,7 +1079,7 @@
10791079
"refresh_now": "↻ 지금 새로고침",
10801080
"analyze_usage": "리포트",
10811081
"analysis_failed": "분석 보고서 생성 실패",
1082-
"install_hook": "훅 설치",
1082+
"install_hook": "상태 표시줄 설정",
10831083
"quit": "⏻ 종료",
10841084
"usage_title": "사용량",
10851085
"current_label": "현재",
@@ -1101,7 +1101,7 @@
11011101
"loading": "",
11021102
"no_data": "",
11031103
"no_agent": "",
1104-
"hook_not_installed": "",
1104+
"hook_not_installed": "상태 표시줄이 설정되지 않았습니다. 실행하세요: usage setup",
11051105
"detected": "",
11061106
"agent_not_found": "",
11071107
"unknown_cmd": "",

menubar.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -830,6 +830,14 @@ def _status_message_value(self, outcome: PollOutcome, fallback_key: str) -> str:
830830
return _t(self.language, "awaiting_rate_limits")
831831
return outcome.message or _t(self.language, fallback_key)
832832

833+
def _statusline_setup_available(self) -> bool:
834+
try:
835+
import setup_hook
836+
837+
return setup_hook.CLAUDE_SETTINGS.parent.exists() or setup_hook.CODEX_CONFIG.exists()
838+
except Exception:
839+
return False
840+
833841
def _state_from_outcome(
834842
self,
835843
outcome: PollOutcome,
@@ -915,7 +923,9 @@ def _state_from_outcome(
915923
status_text=status_text,
916924
today_text=today_text,
917925
statusline=_statusline_payload(self.language),
918-
show_install_button=outcome.state == PollState.TOKEN_ERROR,
926+
show_install_button=(
927+
outcome.state == PollState.TOKEN_ERROR and self._statusline_setup_available()
928+
),
919929
)
920930

921931
def _codex_rows(self) -> tuple[tuple[QuotaRowState, QuotaRowState], int | None, str]:

0 commit comments

Comments
 (0)