Skip to content

ryanrhughes/codexbar-waybar

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

codexbar-waybar

Waybar custom module for CodexBar usage data.

It shows Codex and Claude remaining usage in the bar and renders a rich tooltip with:

  • session and weekly meters
  • CodexBar-compatible pace wording (in deficit, in reserve, Expected X% used)
  • reset countdowns
  • run-out / lasts-until-reset projection
  • Codex credits when available

Requirements

  • Arch Linux / Waybar
  • jq
  • Ruby for the installer/uninstaller helpers

The package bundles the upstream CodexBar Linux CLI release from https://github.com/steipete/codexbar and installs it as /usr/bin/codexbar, so a separate CodexBar or Homebrew install is not required.

If you previously had a hand-written ~/.local/bin/codexbar-waybar, remove it; otherwise it can shadow the packaged executable. If you have another codexbar binary you intentionally want to use, set CODEXBAR_BIN.

Build the Arch package

cd ~/Work/codexbar-waybar
makepkg -si

The package downloads CodexBar CLI from GitHub releases and installs:

  • /usr/bin/codexbar
  • /usr/lib/codexbar-waybar/CodexBarCLI
  • /usr/bin/codexbar-waybar
  • /usr/bin/codexbar-waybar-install
  • /usr/bin/codexbar-waybar-uninstall
  • /usr/share/codexbar-waybar/waybar/codexbar.jsonc
  • /usr/share/codexbar-waybar/waybar/codexbar.css
  • /usr/share/codexbar-waybar/waybar-tooltip.jq

Add to Waybar

After installing the package:

codexbar-waybar-install

The installer updates ~/.config/waybar/config.jsonc and ~/.config/waybar/style.css by:

  1. adding an include for /usr/share/codexbar-waybar/waybar/codexbar.jsonc
  2. adding custom/codexbar to modules-right immediately after Omarchy's group/tray-expander when present
  3. importing /usr/share/codexbar-waybar/waybar/codexbar.css
  4. reloading Waybar with SIGUSR2

Backups are created before changes.

To install into another section:

codexbar-waybar-install --section modules-left
codexbar-waybar-install --section modules-center
codexbar-waybar-install --section modules-right

Useful options:

codexbar-waybar-install --dry-run
codexbar-waybar-install --after group/tray-expander
codexbar-waybar-install --after ''       # prepend if you do not want target placement
codexbar-waybar-install --no-css
codexbar-waybar-install --no-reload
codexbar-waybar-install --config-dir ~/.config/waybar

Remove from Waybar

Run this before uninstalling the package:

codexbar-waybar-uninstall

It removes the module from the configured section, removes the include, removes the CSS import, and reloads Waybar.

Development from the repo

You can test without installing to /usr:

cd ~/Work/codexbar-waybar
CODEXBAR_WAYBAR_FILTER="$PWD/share/codexbar-waybar/waybar-tooltip.jq" \
  ./bin/codexbar-waybar | jq .

To test the installer against the repo snippets:

CODEXBAR_WAYBAR_SHARE_DIR="$PWD/share" ./bin/codexbar-waybar-install --dry-run

Configuration

The module reads these environment variables:

Variable Default Description
CODEXBAR_BIN codexbar CodexBar executable
CODEXBAR_WAYBAR_SOURCE cli CodexBar source passed to codexbar usage
CODEXBAR_WAYBAR_PROVIDER all CodexBar provider passed to codexbar usage; use both for Codex + Claude only
CODEXBAR_WAYBAR_ACCOUNT unset Passed as --account
CODEXBAR_WAYBAR_ACCOUNT_INDEX unset Passed as --account-index
CODEXBAR_WAYBAR_ALL_ACCOUNTS unset When true, passes --all-accounts
CODEXBAR_WAYBAR_NO_CREDITS unset When true, passes --no-credits
CODEXBAR_WAYBAR_WEB_TIMEOUT unset Passed as --web-timeout
CODEXBAR_WAYBAR_EXTRA_ARGS unset Extra whitespace-split args appended to codexbar usage
CODEXBAR_WAYBAR_SHOW_ERRORS auto auto hides unsupported-provider noise when any provider has data; always shows all provider errors
CODEXBAR_WAYBAR_CACHE_MAX_AGE 1800 Cache TTL in seconds
CODEXBAR_WAYBAR_FILTER /usr/share/codexbar-waybar/waybar-tooltip.jq jq tooltip renderer
CODEXBAR_WAYBAR_PATH common user/system paths PATH used by the module

Waybar snippet

The installed include defines:

{
  "custom/codexbar": {
    "exec": "codexbar-waybar",
    "return-type": "json",
    "interval": 1800,
    "format": "{}",
    "escape": false,
    "tooltip": true
  }
}

About

Waybar module for CodexBar Codex and Claude usage

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors