Skip to content

FelipeMayerDev/plasma-applet-zaimeter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ZAI Meter - Plasma Applet

image

A KDE Plasma 6 widget for monitoring GLM Coding Plan usage via Z.ai API.

Features

  • Token Usage Monitoring - Tracks token usage in 5-hour windows
  • MCP Usage Monitoring - Tracks MCP usage monthly limits
  • Real-time Updates - Automatic polling with configurable intervals
  • Compact Display - Shows usage in panel as bars or gauge
  • Detailed View - Full popup with usage breakdown
  • Configurable Thresholds - Set warning and critical percentages
  • Platform Detection - Automatically detects Z.ai or ZHIPU platform
  • Token Details - Shows input/output tokens and request counts
  • Local Cache - Caches responses to avoid rate limiting

Requirements

  • KDE Plasma 6
  • Python 3
  • curl
  • jq (optional, for JSON handling)
  • GLM Coding Plan credentials in ~/.local/share/opencode/auth.json

Installation

Manual Installation

  1. Copy widget directory to plasma plasmoids folder:
cp -r plasma-applet-zaimeter ~/.local/share/plasma/plasmoids/com.github.focky.glmmeter
  1. Reload Plasma shell:
plasmashell --replace
  1. Add widget to your panel:
    • Right-click on panel → Add Widgets…
    • Search for "GLM Meter"
    • Add to panel

Using Installation Script

cd plasma-applet-zaimeter
./install.sh

Configuration

Credentials

The widget reads your GLM API credentials from:

~/.local/share/opencode/auth.json

The file should contain your API key in zai-coding-plan section:

{
  "zai-coding-plan": {
    "type": "api",
    "key": "your-api-key-here"
  }
}

Widget Settings

Right-click on widget → Configure GLM Meter:

  • Poll interval: How often to refresh data (60-3600 seconds)
  • Warning threshold: Percentage for warning color (default: 80%)
  • Critical threshold: Percentage for critical color (default: 95%)
  • Style: Display as bars or gauge
  • Compact metric: Which metric to show in gauge mode (token_quota or time_quota)
  • Gauge label: What to show inside gauge (percent or label)

Colors

  • Normal usage: Blue (#2196F3) - Below warning threshold
  • Warning usage: Yellow (#E5C07B) - Above warning threshold
  • Critical usage: Red (system theme) - Above critical threshold

API Endpoints

The widget uses these Z.ai API endpoints:

  • /api/monitor/usage/model-usage - Model token usage
  • /api/monitor/usage/tool-usage - Tool usage
  • /api/monitor/usage/quota/limit - Quota limits

Development

Based on ClaudeMeter by p3kj.

File Structure

plasma-applet-zaimeter/
├── metadata.json              # Plasma widget metadata
├── README.md                  # This file
├── LICENSE                    # MIT License
├── install.sh                 # Installation script
├── uninstall.sh               # Uninstallation script
├── reset.sh                  # Hard reset script
├── update.sh                 # Update script
└── contents/
    ├── config/               # Configuration
    │   ├── config.qml
    │   ├── ConfigGeneral.qml
    │   └── main.xml
    ├── scripts/              # Backend scripts
    │   └── fetch_usage.sh    # API fetch script
    └── ui/                   # QML UI
        ├── main.qml
        ├── CompactRepresentation.qml
        ├── FullRepresentation.qml
        ├── GaugeRepresentation.qml
        ├── BarsRepresentation.qml
        └── UsageBar.qml

Troubleshooting

Widget not showing data

  1. Check that your credentials file exists and is valid:
cat ~/.local/share/opencode/auth.json
  1. Test the fetch script manually:
bash ~/.local/share/plasma/plasmoids/com.github.focky.glmmeter/contents/scripts/fetch_usage.sh
  1. Check Plasma logs:
journalctl --user -u plasmashell -f

Rate limit errors

The widget implements exponential backoff. If you see rate limit errors, the widget will use cached data if available and increase the backoff multiplier.

Platform detection issues

The widget automatically detects Z.ai vs ZHIPU based on your base URL. If you need to force a specific platform, set the GLM_BASE_URL environment variable:

export GLM_BASE_URL="https://api.z.ai"

License

MIT

Credits

  • Original ClaudeMeter by p3kj
  • GLM Coding Plan API documentation

About

KDE Plasma 6 widget for monitoring GLM Coding Plan usage via Z.ai API

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors