A KDE Plasma panel widget showing how much Claude Max quota is left, at a glance.
README.md

dipstick #

A KDE Plasma panel widget showing how much Claude Max quota is left, at a glance.

The dipstick widget in the Plasma panel

In the panel it is a percentage and a five-dot level: the window that will run out first. Clicking it opens the detail.

The dipstick popup

(Both screenshots are taken against sample data: the account is fictitious and the figures are made up, so that the widget is shown doing its job rather than showing a quiet afternoon. They are drawn with the CQ Fabrication colour scheme; under any other scheme the widget takes that scheme's text and accent colours, Breeze's blue included.)

Why it exists #

Working with Claude Code on a Max subscription, there is no way to know how much quota is left without stopping and running /usage inside a session. You discover the limit by hitting it, which is always the worst moment. An indicator that is always visible in the panel takes the question away.

Scope #

  • A QML plasmoid for Plasma 6 on Wayland, in the panel, with a detail popup on click.
  • Shows the 5-hour window and the week: percentage used and reset time.
  • Shows the per-model breakdown the endpoint provides, with the names it sends: the scoped window is generic, not fixed to Opus/Sonnet.
  • Reads the quota from GET https://api.anthropic.com/api/oauth/usage using its own OAuth flow.
  • If the endpoint does not answer, it degrades onto local transcripts (~/.claude/projects/**/*.jsonl) and says explicitly that the quota is unavailable.

Non-goals #

  • No notifications. The widget is passive: you look at it, it does not interrupt. No configurable thresholds, no KDE notifications.
  • No analytics. No trends, no projected burn rate, no per-project ranking, no session lists. It is a widget, not an analytics application. Revised in flight: the 30-day daily chart was excluded by this point and was reintroduced on explicit request — it is a histogram of totals, not a series to analyse.
  • No multi-account support. One subscription, the configured one.
  • Not a Claude client. It starts no sessions, does not talk to Claude Code, and does nothing beyond reading and displaying.
  • No X11 and no other desktops. Plasma 6 on Wayland, full stop. If it is needed elsewhere, that is a different project.

Decisions already made #

  • Thin QML plasmoid plus a Go daemon. The plasmoid runs inside the plasmashell process: parsing over a gigabyte of jsonl there means a memory spike or a crash takes the whole panel down. The daemon does the parsing, OAuth, polling and caching, and exposes a tiny JSON state; the plasmoid reads only that and draws.
  • Go for the daemon, because it is a single binary with no runtime to install in the panel's context, and it is fast over the transcript volume.
  • Its own OAuth, not Claude Code's credentials. A dedicated PKCE flow, with the token in the project's own directory. Two processes refreshing the same token can invalidate each other: the risk of dropping the CLI session is not worth the saved login.
  • State through a JSON file, not D-Bus or a socket. The daemon writes ~/.config/dipstick/state.json atomically (write plus rename) and the plasmoid re-reads it on a timer. It is the only option that keeps the plasmoid pure QML: Qt 6 and Plasma 6 ship no QML module for D-Bus or for unix sockets, so either would force a C++ plugin and the end of installing with kpackagetool6 alone. The state also survives a daemon restart and can be inspected with cat.
  • The read goes through Plasma5Support.DataSource (executable plus cat), not XMLHttpRequest. Verified in the field: Qt 6 answers "XMLHttpRequest: Using GET on a local file is disabled by default" and only unlocks it with QML_XHR_ALLOW_FILE_READ=1 in plasmashell's environment — that is, by loosening that protection for all of the panel's QML and reaching into the user's session. Forking cat every fifteen seconds costs less than either.
  • Its own icon, shipped and installed into hicolor. The obvious theme icon was speedometer, but a speedometer reads a level with a needle and this reads it the way an oil dipstick does, by pulling it out. The drawing lives in plasmoid/contents/icons/dipstick.svg and is monochrome on purpose: it is painted as a mask filled with the theme's text colour, so one file covers light and dark. It is installed a second time into share/icons/hicolor/scalable/apps/, because Icon in metadata.json is resolved against the icon theme and not against the package — without that copy the widget shows a blank page in the "Add Widgets" list.
  • Quota polling every 5 minutes, adaptive. Server-side, utilization moves about every 5 minutes: asking more often repeats the same answer. It slows to 15–30 minutes when local transcripts show no recent activity, and returns to 5 minutes as soon as work resumes.
  • Transcripts read incrementally, with the cache in memory. At first the mtime filter was enough: a file untouched for 30 days cannot contain lines from the last 30, and on a 146 MB tree a full read took 850 ms. The history outgrew it — 316 files and 1.5 GB, all touched within the month, so the filter skipped nothing and a round took ~11 s, almost all of it re-parsing tool output already read five minutes earlier. The daemon now remembers, per file, where it stopped and what it found, and reads only what Claude Code appended: a round with nothing new costs milliseconds. A file that shrank or was replaced is read again from the start, a half-written last line waits for the next round, and the cache never leaves the daemon's memory — it never lands on disk, least of all under ~/.claude/projects/. The first round after a start still reads everything.
  • The daemon as a resident systemd user unit. Adaptive backoff and the OAuth token live in the process rather than smeared across a timer's configuration; on top of that come automatic restarts and logs in journalctl. Its lifecycle stays independent of plasmashell, which restarts often. The user enables the unit by hand: dipstick does not touch the desktop session.
  • In the panel: the percentage that binds first, with a level of the same figure. The compact representation is ~34px tall: a number reads out of the corner of your eye, two graphics do not. It shows the higher of the 5-hour and weekly windows, that is, the constraint hit first. Revised in flight: the bar used to show the second window, but a number and a bar side by side reporting different values read as incoherent. They are now the same figure in two shapes, and the second window lives in the tooltip and the popup. Revised again: the bar became five dots, after the CQ Fabrication redesign; a vertical panel stacks the number over the dots.
  • Colours from the Plasma theme, not a palette of its own. The layout — the dot-matrix figure, the cards, the dotted bars — is dipstick's; the colours are the user's scheme: text, inactive text, background and accent. Plasma's theme has no roles for the in-between tones (a card a step above the popup, an unlit dot, faint text), so those are the text colour at reduced alpha, which sits correctly on a light popup, a dark one or glass. The chart tells models apart by tone — accent, darker accent, inactive and faint text — rather than by hue: the stacking order and the legend underneath carry the difference, and a scheme with one accent keeps one accent.
  • Distribution: clone it and build it. make install compiles the daemon into ~/.local/bin, puts the unit in ~/.config/systemd/user and registers the plasmoid with kpackagetool6: it is the only form that installs both halves together. No KDE Store: it distributes the QML package only, and a widget without its daemon is broken by construction. No prebuilt binaries: an RPM built here is only valid for the same architecture and the same Fedora release, and publishing it would imply otherwise. The spec exists (make rpm) for whoever wants to build the package, not to distribute it.
  • Read limits[], not five_hour/seven_day. Verified in the field: seven_day_opus and seven_day_sonnet come back null, and the per-model breakdown exists only inside limits[], with the model name chosen by the server. The top-level fields remain as a fallback. limits[] also carries severity, meaning Anthropic already decides the thresholds and we do not have to invent any.
  • OAuth scope reduced to user:profile user:inference. The prior art also asks for org:create_api_key, which exists to create API keys: dipstick only reads. Verified that the quota endpoint answers just the same.
  • A hybrid with degradation, not a single source: the quota is precise but rests on an undocumented endpoint, the transcripts are reliable but know nothing about limits.

Data source contract #

The quota endpoint is undocumented — it can change without notice. The shape below was verified in the field on 2026-08-27, not inferred: fixture in internal/anthropic/testdata/usage.json.

GET https://api.anthropic.com/api/oauth/usage
  Authorization: Bearer <token>
  anthropic-beta: oauth-2025-04-20
  anthropic-version: 2023-06-01
  User-Agent: claude-cli/<version> (external, cli)

The source to read is limits[], not the top-level fields:

limits: [ { kind:     "session" | "weekly_all" | "weekly_scoped",
            group:    "session" | "weekly",
            percent:   integer 0-100,
            severity: "normal" | ...,      <- thresholds already set by the server
            resets_at: RFC3339 | null,
            is_active: bool,               <- which window is accumulating
            scope:     null | { model: { display_name } } } ]

five_hour and seven_day still exist and stay consistent with limits[] (utilization is a float, e.g. 30.0, while limits[].percent is an integer): they are used only as a fallback when limits is missing or empty.

seven_day_opus and seven_day_sonnet come back null: the per-model breakdown lives only in limits[] with kind: weekly_scoped, and scope.model.display_name carries the name the server picks (on the test account: Fable). Render it as it arrives.

The response also contains code-named fields (tangelo, iguana_necktie, nimbus_quill, seven_day_cowork, omelette_promotional, ...), almost all null: unannounced features. Every unrecognised field is ignored silently.

extra_usage and spend describe credits beyond the plan. Out of scope, but with extra_usage.is_enabled: true reaching 100% stops being a wall, and the widget would be wrong to show it as one.

GET /api/oauth/profile (same headers) gives account.email, account.display_name, account.has_claude_max / has_claude_pro, and organization.rate_limit_tier.

Local fallback: ~/.claude/projects/**/*.jsonl, one JSON object per line, with a usage field per message carrying input_tokens, cache_creation_input_tokens, cache_read_input_tokens and output_tokens.

Contract between daemon and plasmoid #

$XDG_CONFIG_HOME/dipstick/state.json (0644), rewritten atomically (write to a temporary file plus rename): the plasmoid re-reads without coordination, so it must always see either the old file or the new one, never half a JSON document.

schema: integer, versioned. The plasmoid refuses a schema it does not know
        rather than draw arbitrary numbers.
quota:  { status: "fresh" | "stale" | "unavailable",
          fetched_at,          <- the last SUCCESSFUL read, not this round
          error, needs_auth }  <- "log in again" vs "try later"
compact: null | { primary, secondary }   <- already chosen by the daemon
windows: [ window, ... ]                 <- detail for the popup
extra_usage_enabled: bool
account: null | { email, name, plan }    <- from /api/oauth/profile
local:   null | { scanned_at, last_activity, messages,
                  session_tokens, today_tokens, week_tokens, month_tokens,
                  models: [ {id, tokens, messages} ],        <- 30 days
                  daily:  [ {date, tokens, models{id:n}} ] } <- 30 days, continuous

window: { kind, group, percent, severity, resets_at, is_active, model? }

Two rules, both there to keep the plasmoid stupid:

  • No interface strings. Only semantic kind values and the model name as the server sends it. Localisation belongs to the plasmoid, which has i18n() and follows the session language; the daemon runs with no locale context and would have to be restarted to change it.
  • The daemon makes the decisions. compact.primary is already the constraint hit first — the higher of session and week, with the week winning ties because the session refills within hours and the week does not. Per-model windows never enter the panel: a high scoped window does not block, you switch model. QML only draws.

compact: null means no data: the plasmoid shows a dash, not a zero.

account.plan ("Max 20x") comes from organization.rate_limit_tier, which tells 5x from 20x where has_claude_max does not. It is a product name, not translated text, which is why it can live in the file.

local.models, local.daily and month_tokens all cover the same 30 calendar days, so the legend, the chart and the total genuinely agree — a rolling boundary for the totals against a calendar boundary for the chart left a sliver of messages counted but never drawn. daily is continuous: days without activity stay in the series at zero, because dropping them would compress time and make intermittent work look steady. Reading the 30 days in full costs ~9 s on a real tree (320 files, 1.6 GB): the daemon pays it once at start, then only for what was appended; dipstick state pays it every time.

Assumptions #

  • The subscription is Claude Max (rateLimitTier: default_claude_max_20x). Behaviour on Pro has not been verified.

Prior art #

renatoaug/claude-usage-monitor ("Clauddy") solves the same problem on macOS and is the source of the contract above. The data architecture is identical (OAuth for the percentages, local jsonl for the tokens); the form is not transferable: it is an Electron desktop pet in a floating window, and on Wayland a client can neither position itself freely nor force itself always-on-top.

Building, installing, testing #

Clone it and compile it: there are no prebuilt packages.

git clone git@knot.onlocalhost.dev:did:plc:rbcfy73ptg6imwluuy6v6jh6 dipstick
cd dipstick
make install

The other targets:

make            # build the daemon and the translation catalogues
make test       # unit tests, no network
make vet        # go vet, and fail on anything not gofmt-ed
make extract    # re-extract the translatable strings from the QML
make install    # daemon into ~/.local/bin, unit into ~/.config/systemd/user,
                # icon into ~/.local/share/icons/hicolor,
                # plasmoid through kpackagetool6

For a package, instead of the home directory:

make install DESTDIR=/path/to/buildroot PREFIX=/usr SYSTEM=1

SYSTEM=1 touches neither systemd nor kpackagetool6: inside a buildroot that would make no sense, and the package scriptlets handle it.

make rpm builds the package (it needs rpm-build). The tarball comes from HEAD, not the working tree: whatever is uncommitted does not end up in the package. If Go is installed outside RPM — mise, the official tarball — the BuildRequires will not resolve and you need:

make rpm RPMBUILD_FLAGS=--nodeps

Verified on Fedora 44 aarch64. Never been through COPR, which also builds for other architectures and releases.

Then these steps, which stay with the user because dipstick does not touch the session:

dipstick auth                              # OAuth login (opens the browser)
systemctl --user enable --now dipstick     # start the daemon

and finally "Add Widgets" → Dipstick in the panel.

Useful for diagnosis:

dipstick usage     # the endpoint's raw JSON, uninterpreted
dipstick state     # the state the plasmoid would read, without writing it
dipstick refresh   # what the popup's refresh button does: one round, now
journalctl --user -u dipstick -f

To work on the plasmoid without the panel: plasmawindowed org.kde.plasma.dipstick. QML errors land in the user journal, not on the terminal. Note that plasmashell does not re-read the QML after an upgrade — it needs systemctl --user restart plasma-plasmashell.service — while plasmawindowed always sees the latest build.

Code layout #

cmd/dipstick/          the CLI and the daemon's entry point
internal/anthropic/    OAuth PKCE, quota/profile endpoints, normalisation
internal/transcript/   READ-ONLY reading of the local transcripts
internal/state/        the state.json schema and the atomic write
internal/daemon/       the loop: adaptive cadence, backoff, degradation
plasmoid/              the QML package, icon included
docs/                  the screenshots used here
translations/          .pot, .po catalogues and the extraction script
packaging/             systemd user unit (template) and the RPM spec

Status #

Working end to end: daemon, plasmoid, degradation and installation. The endpoint contract is verified against the real endpoint, not inferred.

The plasmoid's strings go through i18n(); an Italian catalogue exists (translations/it.po), compiled by make and installed inside the plasmoid package.

The RPM spec has been built and the package inspected: it contains the binary, the unit, the plasmoid, the icon, the catalogue and the licence, and the unit points at /usr/bin/dipstick. It has never been through COPR.