z.ai GLM coding plan bar widget for Omarchy: usage, peak hours, promotions
  • QML 56.6%
  • JavaScript 43.4%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Sebastian B 27c389aedf ZCode GLM: distinguish no-key from pre-first-fetch in the tooltip
tooltipLines(now, usage, hasKey) takes the key state separately, so
hovering during the 3s startup window shows Waiting for the first fetch
instead of wrongly claiming no API key is set; also drops the redundant
!(usage && usage.ok) conjunct
2026-09-04 01:03:23 +01:00
docs/screenshots ZCode GLM: z.ai coding plan bar widget for Omarchy 2026-09-03 21:42:30 +01:00
test ZCode GLM: distinguish no-key from pre-first-fetch in the tooltip 2026-09-04 01:03:23 +01:00
BarWidget.qml ZCode GLM: distinguish no-key from pre-first-fetch in the tooltip 2026-09-04 01:03:23 +01:00
LICENSE ZCode GLM: z.ai coding plan bar widget for Omarchy 2026-09-03 21:42:30 +01:00
manifest.json ZCode GLM: z.ai coding plan bar widget for Omarchy 2026-09-03 21:42:30 +01:00
Model.js ZCode GLM: distinguish no-key from pre-first-fetch in the tooltip 2026-09-04 01:03:23 +01:00
Panel.qml ZCode GLM: hide ended promos, null-safe percentages, multi-promo selection 2026-09-04 00:55:45 +01:00
preview.png ZCode GLM: z.ai coding plan bar widget for Omarchy 2026-09-03 21:42:30 +01:00
README.md README: install over SSH, not HTTPS 2026-09-03 23:14:02 +01:00

ZCode GLM

An Omarchy bar widget for the z.ai GLM coding plan: what your tokens cost right now, what you have spent, and what is being given away.

Bar widget showing the active promo glyph and 5-hour usage

Details panel: peak state, live quota, promotion, credit rates

kind shell

What it shows

Bar label — a glyph for the current pricing state plus the 5-hour token percentage (when ZAI_API_KEY is set in the shell environment):

  • ∞ — a promotion window is open (unlimited GLM-5.3-Flash in ZCode)
  • ☀ — peak hours (Mon–Fri 14:00–18:00 SGT, full credit rate)
  • ☾ — off-peak (credits charged at 50%)

The label lights up in the urgent color when the 5-hour window is nearly spent. Left click opens the details panel, right click re-fetches usage.

Details panel — everything rendered in your local timezone:

  • Local time and timezone abbreviation
  • Peak/off-peak state with a countdown to the next flip and today's window in local time
  • Live quota from the z.ai usage API (5-hour token window, monthly MCP calls, credit windows), with reset times
  • Current promotion: status, daily window in local time, benefits, link
  • Credit-rate reference table and the reset rules

Install

omarchy plugin add [email protected]:wmc/omarchy-zcode-plugin.git --enable

Or copy the folder to ~/.config/omarchy/plugins/sbochna.zcode/ and run omarchy-shell shell rescanPlugins, then enable it from omarchy plugin list.

Configure

The API key is read from the ZAI_API_KEY environment variable of the shell process — the same key your coding-plan agent uses (z.ai console). It is never written to disk and never passed on a command line: the widget hands it to curl over stdin. If the variable is missing, the widget shows the pricing glyph only and the panel explains how to fix it.

Other settings live in the widget's inline entry in ~/.config/omarchy/shell.json:

Setting Default Meaning
endpoint https://api.z.ai/api/monitor/usage/quota/limit Usage API endpoint (mainland China plans: https://open.bigmodel.cn/api/monitor/usage/quota/limit)
pollMinutes 10 Minutes between usage fetches

The endpoint mirrors the one the plexus gateway and z.ai's own usage-query plugin call, with Authorization: Bearer.

IPC

omarchy-shell shell summon sbochna.zcode '{}'   # open the panel
omarchy-shell shell hide sbochna.zcode          # close it
qs -c omarchy-shell ipc call sbochna.zcode refresh

Theme

No colors are hardcoded: every surface uses the shell's palette roles (foreground, accent, urgent, muted) and Style tokens, so the widget follows whatever theme you switch to.

Development

# sync the working copy into the live plugin folder (tests, docs, git
# metadata, and the repo preview stay local)
rsync -a --exclude test/ --exclude .git --exclude docs --exclude preview.png \
  ./ ~/.config/omarchy/plugins/sbochna.zcode/

node test/model-test.cjs          # pure logic (peak/promo/parse) tests
omarchy plugin validate ~/.config/omarchy/plugins/sbochna.zcode
qmllint -I "$OMARCHY_PATH/shell" ~/.config/omarchy/plugins/sbochna.zcode/*.qml

Note: the QML engine caches compiled plugin files, so after editing QML run omarchy restart shell (plugin hot-reload alone can keep serving the old unit).

Remove

omarchy plugin remove sbochna.zcode

License

MIT