Skip to content
Script-hppPublic

About

Claude Code usage monitor for KDE Plasma

Resources

Stars

3 stars

Watchers

0 watching

Forks

Latest commit

 

History

40 Commits

Folders and files

Repository files navigation

usagemon

Available on the KDE Store

A KDE Plasma 6 panel widget that shows your Claude Code, Codex, Cline, Antigravity (agy) and OpenCode Go subscription usage (session, weekly and other rate limits) at a glance, so you don't have to type /usage in a terminal every time.

It reads your usage in the background and shows a compact, color-coded readout in your panel. Click it for a popup with the full breakdown and reset times. In the widget's settings, tick exactly the items you want listed (any mix of Claude Code, Codex, Cline, Antigravity's Gemini quota, Antigravity's Claude + GPT quota, and OpenCode Go), and for each one, which of its limits the panel shows (e.g. Claude Code's 5-hour and weekly usage, but only Gemini's weekly usage).

Panel readout for one item: Claude Code's 5-hour and weekly usage    Panel readout for several items: Claude Code and Codex (5-hour + week), Gemini (week only), Cline (5-hour only)

Claude Code usage popup (wider layout, with countdown + absolute reset time)    Codex usage popup (normal layout), with a per-model limit

Settings dialog

usagemon settings: General page, picking items and which limits each shows in the panel

usagemon settings: Appearance page

Features

  • Panel readout: session and week usage side by side (e.g. 29% · 36%), each preceded by its own Breeze icon: a stopwatch for the session limit and a week-calendar for the weekly limit (the icons can be turned off). Per item you pick which limits appear: 5-hour, week and/or month.
  • Severity colors: the percentages and icons turn from green → yellow → red. When the OAuth API is used, this follows the API's own severity for each limit; otherwise it falls back to configurable warning/critical thresholds.
  • Detail popup: per-limit progress bars (session, week, plus any extra limits such as a per-model weekly limit) with a live reset countdown (e.g. resets in 2h 14m). Enable Wider layout to also show the absolute time (resets in 2h 14m · Jul 11, 5:59pm).
  • Notifications: optional desktop notification when a limit crosses a configurable threshold (default 90%).
  • Active model: reads your configured model from ~/.claude/settings.json (or the active quota group for Antigravity) and shows it, with its brand icon, in the popup header and tooltip.
  • Pick what's listed: any combination of Claude Code, Codex, Cline, Antigravity (Gemini and Claude + GPT quotas separately) and OpenCode Go. With several items, the panel shows one indicator each; click one to open its details (click it again to close), or switch between them in the popup.
  • Gentle on rate limits: every service is polled on its own schedule and backs off on errors, so one failing source never makes the others refetch.
  • Auto refresh on a configurable interval, plus manual refresh (middle-click the panel item, the popup's refresh button, or the context menu).

Requirements

  • KDE Plasma 6 and python3 (used by the bundled fetch script)
  • Whichever of these you want to monitor, installed and logged in. usagemon reuses that existing login; you don't authenticate separately.
    • Claude Code
    • Codex CLI, signed in with ChatGPT (an API-key login has no plan limits to show)
    • Cline's CLI
    • Antigravity's agy CLI, recent enough to have agy usage
    • OpenCode with an OpenCode Go subscription: connect it in opencode (/connect → OpenCode Go), or set OPENCODE_GO_API_KEY. The key needs the usage:read permission (opencode.ai console → API keys).

Install

Option A (from the KDE Store, easiest): right-click your panel → Add Widgets… → Get New Widgets… → search for usagemon (or install it directly from store.kde.org).

Option B (from source):

git clone https://github.com/Script-hpp/usagemon.git
cd usagemon
./install.sh

Then right-click your panel → Add Widgets… → search for usagemon and add it.

Important

After installing or updating, log out and back in (or reboot). Plasma keeps the old widget code loaded in memory, so just re-adding the widget or running plasmashell --replace is not always enough. If you still see an old error such as bash: claude: command not found after an update, this is why.

Uninstall

./uninstall.sh

Configuration

Right-click the widget → Configure usagemon…. General holds what to monitor and how (the items through the poll interval below); Appearance holds the rest:

Option Default Description
Show usage for Claude Code Tick any of Claude Code, Codex, Cline, Antigravity · Gemini, Antigravity · Claude + GPT, OpenCode Go (at least one). Settings from before 1.1 are carried over
Panel limits (next to each item) 5-hour + Week Which of that item's limits the panel shows: 5-hour, Week, and (Cline, OpenCode) Month, at least one. The popup always shows every limit. If a plan doesn't have the picked window (e.g. a Codex free plan has only a weekly one), the panel shows what there is
Claude Code source Automatic Automatic (OAuth API, then CLI), OAuth API only, or CLI only (Claude Code only)
Claude command claude Path/name of the claude binary (used by the CLI source). ~/.local/bin is added to PATH automatically, so the native installer location works out of the box
Poll interval (seconds) 120 How often to refresh (min 60; the source is rate-limited)
Panel: 5-hour / week icons on Show a stopwatch / calendar icon before each panel number
Warn threshold (%) 75 Usage at which the readout turns yellow (when no API severity)
Critical threshold (%) 90 Usage at which the readout turns red (when no API severity)
Notifications on Notify when a limit is high
Notify threshold (%) 90 Usage at which a notification fires
Wider layout off Widen the popup and add the absolute reset time next to the countdown

How it works

Everything is fetched by one bundled script, usagemon_fetch.py, run once per service (usagemon_fetch.py claude|cline|antigravity|opencode). It prints the same normalized JSON for every service, so you can also run it by hand to see exactly what the widget sees.

Claude Code

There is no public Anthropic API for Claude Code's subscription rate limits (session %, week %). usagemon gets them the same way the CLI itself does:

  1. OAuth API (primary). The OAuth access token is read from Claude Code's own credentials file (~/.claude/.credentials.json, claudeAiOauth) and used for GET https://api.anthropic.com/api/oauth/usage, the endpoint the claude CLI uses internally. An expired token is not sent; the CLI fallback runs instead (and refreshes the login as a side effect).
  2. CLI (fallback). If the API is unavailable (no token, expired token, offline, rate limited), it runs claude -p /usage and parses the text.

You choose the mode in the settings (Automatic / API only / CLI only).

Cline support

There is no public Cline API for rate limits either, so usagemon reuses the existing local Cline login: it reads ~/.cline/data/settings/providers.json (the file Cline's CLI itself writes) and takes the access token of the last-used provider (providers.<name>.settings.auth.accessToken), falling back to any other configured provider with a still-valid token. That works whichever Cline provider you're on (native "API" credits, Cline Pass, or another one), since they share the same account-wide endpoint: GET https://api.cline.bot/api/v1/users/me/plan/usage-limits. The five_hour, weekly and monthly limits are shown. Cline has no CLI usage command, so if the API is unavailable the widget shows the last known values and retries.

Privacy

  • usagemon reuses your existing local logins: no separate sign-in, no passwords.
  • Each token is read locally and only ever sent to its own tool's usage endpoint (api.anthropic.com, chatgpt.com, api.cline.bot, opencode.ai). Tokens stay inside the fetch script's process: never on a command line (so not visible via ps), never printed, logged, cached or copied elsewhere, and never passed to the widget code.
  • Antigravity is read through agy usage; no Google credentials are touched.
  • No third-party servers are involved.

Antigravity support

Antigravity's quota is read with agy usage --json, the agy CLI's own usage command, so usagemon never touches Google account credentials. agy is looked up on PATH and in ~/.local/bin (or set ANTIGRAVITY_CLI_PATH).

Antigravity pools quota per group rather than per model: Gemini models share one 5-hour and one weekly window, Claude + GPT models share another. Each group is its own item in the settings, so you can list either or both.

Codex support

Codex has no public API for plan limits either. usagemon reads the Codex CLI's own ChatGPT login from ~/.codex/auth.json (or $CODEX_HOME): tokens.access_token and tokens.account_id. It calls GET https://chatgpt.com/backend-api/wham/usage, the endpoint the Codex CLI itself uses for its limits (see codex-rs/backend-client in openai/codex). The primary window (5 hours) and secondary window (weekly) become Session and Week; any model-specific limits are added in the popup. The endpoint only reports your plan (shown as "Plan: Plus" etc.); the model shown next to it is the model set in Codex's own config.toml, if any. usagemon never refreshes or writes Codex's login: if the token has expired, run codex once and it will refresh it. This endpoint is undocumented and may change.

OpenCode Go support

OpenCode Go usage comes from GET https://opencode.ai/zen/go/v1/usage, the endpoint OpenCode Go clients use (it isn't documented as a stable public API, so it may change). The key is taken from OPENCODE_GO_API_KEY, or from OpenCode's own stored opencode-go credential (auth.json or opencode.db in ~/.local/share/opencode), and is sent only to opencode.ai. The rolling (5-hour), weekly and monthly windows are shown.

A note on refresh rate

Claude Code's OAuth usage endpoint is rate limited hard, and Claude Code itself calls it too. So usagemon:

  • reuses an answer that is less than a minute old (shared by every usagemon widget you have, via ~/.cache/usagemon),
  • after an HTTP 429, leaves the endpoint alone for 5 minutes, then 10, 20... up to an hour, and in Automatic mode reads claude -p /usage meanwhile (that keeps working while the endpoint is rate limited; it runs in ~/.cache/usagemon/claude-cli and removes the session it leaves behind),
  • polls each service on its own timer and retries a failed one with backoff, so a failing source never makes the others refetch.

The default poll interval is 2 minutes; the minimum is 60 seconds.

KDE Store

usagemon is published on the KDE Store: https://store.kde.org/p/2365234/

You can install it straight from there via Add Widgets… → Get New Widgets… in Plasma, or download the .plasmoid archive from that page and install it manually:

kpackagetool6 --type Plasma/Applet --install usagemon-<version>.plasmoid

To build a new release archive yourself (e.g. after making changes):

./build-plasmoid.sh    # produces usagemon-<version>.plasmoid

License

MIT, see LICENSE.

About

Claude Code usage monitor for KDE Plasma

Resources

Stars

3 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages