claude-usage-widget 0.2.2__tar.gz → 0.2.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. {claude_usage_widget-0.2.2/claude_usage_widget.egg-info → claude_usage_widget-0.2.3}/PKG-INFO +30 -17
  2. {claude_usage_widget-0.2.2 → claude_usage_widget-0.2.3}/README.md +29 -16
  3. {claude_usage_widget-0.2.2 → claude_usage_widget-0.2.3}/claude_usage/__init__.py +1 -1
  4. {claude_usage_widget-0.2.2 → claude_usage_widget-0.2.3}/claude_usage/notifier.py +27 -10
  5. {claude_usage_widget-0.2.2 → claude_usage_widget-0.2.3}/claude_usage/widget.py +9 -1
  6. {claude_usage_widget-0.2.2 → claude_usage_widget-0.2.3}/claude_usage/widget_macos.py +9 -1
  7. {claude_usage_widget-0.2.2 → claude_usage_widget-0.2.3/claude_usage_widget.egg-info}/PKG-INFO +30 -17
  8. {claude_usage_widget-0.2.2 → claude_usage_widget-0.2.3}/LICENSE +0 -0
  9. {claude_usage_widget-0.2.2 → claude_usage_widget-0.2.3}/MANIFEST.in +0 -0
  10. {claude_usage_widget-0.2.2 → claude_usage_widget-0.2.3}/claude_usage/__main__.py +0 -0
  11. {claude_usage_widget-0.2.2 → claude_usage_widget-0.2.3}/claude_usage/analytics.py +0 -0
  12. {claude_usage_widget-0.2.2 → claude_usage_widget-0.2.3}/claude_usage/api_server.py +0 -0
  13. {claude_usage_widget-0.2.2 → claude_usage_widget-0.2.3}/claude_usage/cli.py +0 -0
  14. {claude_usage_widget-0.2.2 → claude_usage_widget-0.2.3}/claude_usage/collector.py +0 -0
  15. {claude_usage_widget-0.2.2 → claude_usage_widget-0.2.3}/claude_usage/config.py +0 -0
  16. {claude_usage_widget-0.2.2 → claude_usage_widget-0.2.3}/claude_usage/exporter.py +0 -0
  17. {claude_usage_widget-0.2.2 → claude_usage_widget-0.2.3}/claude_usage/forecast.py +0 -0
  18. {claude_usage_widget-0.2.2 → claude_usage_widget-0.2.3}/claude_usage/history.py +0 -0
  19. {claude_usage_widget-0.2.2 → claude_usage_widget-0.2.3}/claude_usage/icons/claude-tray.svg +0 -0
  20. {claude_usage_widget-0.2.2 → claude_usage_widget-0.2.3}/claude_usage/overlay.py +0 -0
  21. {claude_usage_widget-0.2.2 → claude_usage_widget-0.2.3}/claude_usage/overlay_macos.py +0 -0
  22. {claude_usage_widget-0.2.2 → claude_usage_widget-0.2.3}/claude_usage/pricing.py +0 -0
  23. {claude_usage_widget-0.2.2 → claude_usage_widget-0.2.3}/claude_usage/py.typed +0 -0
  24. {claude_usage_widget-0.2.2 → claude_usage_widget-0.2.3}/claude_usage/themes.py +0 -0
  25. {claude_usage_widget-0.2.2 → claude_usage_widget-0.2.3}/claude_usage/trends.py +0 -0
  26. {claude_usage_widget-0.2.2 → claude_usage_widget-0.2.3}/claude_usage/updater.py +0 -0
  27. {claude_usage_widget-0.2.2 → claude_usage_widget-0.2.3}/claude_usage/webhooks.py +0 -0
  28. {claude_usage_widget-0.2.2 → claude_usage_widget-0.2.3}/claude_usage_widget.egg-info/SOURCES.txt +0 -0
  29. {claude_usage_widget-0.2.2 → claude_usage_widget-0.2.3}/claude_usage_widget.egg-info/dependency_links.txt +0 -0
  30. {claude_usage_widget-0.2.2 → claude_usage_widget-0.2.3}/claude_usage_widget.egg-info/entry_points.txt +0 -0
  31. {claude_usage_widget-0.2.2 → claude_usage_widget-0.2.3}/claude_usage_widget.egg-info/requires.txt +0 -0
  32. {claude_usage_widget-0.2.2 → claude_usage_widget-0.2.3}/claude_usage_widget.egg-info/top_level.txt +0 -0
  33. {claude_usage_widget-0.2.2 → claude_usage_widget-0.2.3}/config.json.example +0 -0
  34. {claude_usage_widget-0.2.2 → claude_usage_widget-0.2.3}/docs/integrations/README.md +0 -0
  35. {claude_usage_widget-0.2.2 → claude_usage_widget-0.2.3}/docs/integrations/polybar-module.ini +0 -0
  36. {claude_usage_widget-0.2.2 → claude_usage_widget-0.2.3}/docs/integrations/starship.toml.snippet +0 -0
  37. {claude_usage_widget-0.2.2 → claude_usage_widget-0.2.3}/docs/integrations/tmux.conf.snippet +0 -0
  38. {claude_usage_widget-0.2.2 → claude_usage_widget-0.2.3}/docs/integrations/waybar-module.json +0 -0
  39. {claude_usage_widget-0.2.2 → claude_usage_widget-0.2.3}/docs/integrations/waybar-style.css +0 -0
  40. {claude_usage_widget-0.2.2 → claude_usage_widget-0.2.3}/docs/integrations/zsh-prompt.zsh +0 -0
  41. {claude_usage_widget-0.2.2 → claude_usage_widget-0.2.3}/pyproject.toml +0 -0
  42. {claude_usage_widget-0.2.2 → claude_usage_widget-0.2.3}/requirements-macos.txt +0 -0
  43. {claude_usage_widget-0.2.2 → claude_usage_widget-0.2.3}/setup.cfg +0 -0
  44. {claude_usage_widget-0.2.2 → claude_usage_widget-0.2.3}/tests/test_analytics.py +0 -0
  45. {claude_usage_widget-0.2.2 → claude_usage_widget-0.2.3}/tests/test_api_server.py +0 -0
  46. {claude_usage_widget-0.2.2 → claude_usage_widget-0.2.3}/tests/test_cli.py +0 -0
  47. {claude_usage_widget-0.2.2 → claude_usage_widget-0.2.3}/tests/test_collector.py +0 -0
  48. {claude_usage_widget-0.2.2 → claude_usage_widget-0.2.3}/tests/test_config.py +0 -0
  49. {claude_usage_widget-0.2.2 → claude_usage_widget-0.2.3}/tests/test_exporter.py +0 -0
  50. {claude_usage_widget-0.2.2 → claude_usage_widget-0.2.3}/tests/test_forecast.py +0 -0
  51. {claude_usage_widget-0.2.2 → claude_usage_widget-0.2.3}/tests/test_history.py +0 -0
  52. {claude_usage_widget-0.2.2 → claude_usage_widget-0.2.3}/tests/test_notifier.py +0 -0
  53. {claude_usage_widget-0.2.2 → claude_usage_widget-0.2.3}/tests/test_pricing.py +0 -0
  54. {claude_usage_widget-0.2.2 → claude_usage_widget-0.2.3}/tests/test_themes.py +0 -0
  55. {claude_usage_widget-0.2.2 → claude_usage_widget-0.2.3}/tests/test_trends.py +0 -0
  56. {claude_usage_widget-0.2.2 → claude_usage_widget-0.2.3}/tests/test_updater.py +0 -0
  57. {claude_usage_widget-0.2.2 → claude_usage_widget-0.2.3}/tests/test_webhooks.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: claude-usage-widget
3
- Version: 0.2.2
3
+ Version: 0.2.3
4
4
  Summary: Desktop widget and CLI that shows real-time Claude Code usage limits and cost.
5
5
  Author: Burak
6
6
  License: MIT
@@ -68,41 +68,54 @@ A desktop widget that displays your Claude Code usage limits in real time. Shows
68
68
 
69
69
  ## Installation
70
70
 
71
- ### Linux
71
+ ### Linux (pip — recommended)
72
72
 
73
73
  ```bash
74
- # 1. Install system dependencies (Ubuntu/Debian)
75
- sudo apt install python3-gi python3-gi-cairo python3-cairo gir1.2-ayatanaappindicator3-0.1
74
+ # 1. Install system GTK stack (one-time)
75
+ sudo apt install python3-gi python3-gi-cairo python3-cairo \
76
+ gir1.2-ayatanaappindicator3-0.1 gir1.2-notify-0.7 # Ubuntu/Debian
77
+ # Fedora: sudo dnf install python3-gobject python3-gobject-cairo libappindicator-gtk3 libnotify
78
+ # Arch: sudo pacman -S python-gobject python-cairo libappindicator-gtk3 libnotify
79
+
80
+ # 2. Install the widget itself
81
+ pip install --user --upgrade claude-usage-widget
76
82
 
77
- # Fedora
78
- sudo dnf install python3-gobject python3-gobject-cairo python3-cairo gtk3
83
+ # 3. Run
84
+ claude-usage # launches tray + OSD
85
+ claude-usage --version
86
+ ```
79
87
 
80
- # Arch
81
- sudo pacman -S python-gobject python-cairo gtk3 libappindicator-gtk3
88
+ GNOME users also need the [AppIndicator extension](https://extensions.gnome.org/extension/615/appindicator-support/) for the tray icon.
82
89
 
83
- # 2. Clone and run
90
+ ### Linux (from source)
91
+
92
+ ```bash
84
93
  git clone https://github.com/bozdemir/claude-usage-widget.git
85
94
  cd claude-usage-widget
86
95
  python3 main.py &
87
96
 
88
- # 3. Autostart on login (optional)
97
+ # Autostart on login (optional)
89
98
  ./install.sh
90
99
  ```
91
100
 
92
- ### macOS
101
+ ### macOS (Homebrew — recommended)
102
+
103
+ ```bash
104
+ brew tap bozdemir/tap
105
+ brew install claude-usage-widget
106
+ claude-usage # launches menu bar + OSD
107
+ claude-usage --version
108
+ ```
109
+
110
+ ### macOS (from source)
93
111
 
94
112
  ```bash
95
- # 1. Clone
96
113
  git clone https://github.com/bozdemir/claude-usage-widget.git
97
114
  cd claude-usage-widget
98
-
99
- # 2. Install Python dependencies
100
115
  pip3 install -r requirements-macos.txt
101
-
102
- # 3. Run
103
116
  python3 main.py
104
117
 
105
- # 4. Autostart on login (optional) -- installs a Launch Agent
118
+ # Autostart on login (optional) -- installs a Launch Agent
106
119
  ./install-macos.sh
107
120
  ```
108
121
 
@@ -39,41 +39,54 @@ A desktop widget that displays your Claude Code usage limits in real time. Shows
39
39
 
40
40
  ## Installation
41
41
 
42
- ### Linux
42
+ ### Linux (pip — recommended)
43
43
 
44
44
  ```bash
45
- # 1. Install system dependencies (Ubuntu/Debian)
46
- sudo apt install python3-gi python3-gi-cairo python3-cairo gir1.2-ayatanaappindicator3-0.1
45
+ # 1. Install system GTK stack (one-time)
46
+ sudo apt install python3-gi python3-gi-cairo python3-cairo \
47
+ gir1.2-ayatanaappindicator3-0.1 gir1.2-notify-0.7 # Ubuntu/Debian
48
+ # Fedora: sudo dnf install python3-gobject python3-gobject-cairo libappindicator-gtk3 libnotify
49
+ # Arch: sudo pacman -S python-gobject python-cairo libappindicator-gtk3 libnotify
50
+
51
+ # 2. Install the widget itself
52
+ pip install --user --upgrade claude-usage-widget
47
53
 
48
- # Fedora
49
- sudo dnf install python3-gobject python3-gobject-cairo python3-cairo gtk3
54
+ # 3. Run
55
+ claude-usage # launches tray + OSD
56
+ claude-usage --version
57
+ ```
50
58
 
51
- # Arch
52
- sudo pacman -S python-gobject python-cairo gtk3 libappindicator-gtk3
59
+ GNOME users also need the [AppIndicator extension](https://extensions.gnome.org/extension/615/appindicator-support/) for the tray icon.
53
60
 
54
- # 2. Clone and run
61
+ ### Linux (from source)
62
+
63
+ ```bash
55
64
  git clone https://github.com/bozdemir/claude-usage-widget.git
56
65
  cd claude-usage-widget
57
66
  python3 main.py &
58
67
 
59
- # 3. Autostart on login (optional)
68
+ # Autostart on login (optional)
60
69
  ./install.sh
61
70
  ```
62
71
 
63
- ### macOS
72
+ ### macOS (Homebrew — recommended)
73
+
74
+ ```bash
75
+ brew tap bozdemir/tap
76
+ brew install claude-usage-widget
77
+ claude-usage # launches menu bar + OSD
78
+ claude-usage --version
79
+ ```
80
+
81
+ ### macOS (from source)
64
82
 
65
83
  ```bash
66
- # 1. Clone
67
84
  git clone https://github.com/bozdemir/claude-usage-widget.git
68
85
  cd claude-usage-widget
69
-
70
- # 2. Install Python dependencies
71
86
  pip3 install -r requirements-macos.txt
72
-
73
- # 3. Run
74
87
  python3 main.py
75
88
 
76
- # 4. Autostart on login (optional) -- installs a Launch Agent
89
+ # Autostart on login (optional) -- installs a Launch Agent
77
90
  ./install-macos.sh
78
91
  ```
79
92
 
@@ -1,3 +1,3 @@
1
1
  """Claude Usage Widget — desktop usage tracker for Claude Code."""
2
2
 
3
- __version__ = "0.2.2"
3
+ __version__ = "0.2.3"
@@ -5,6 +5,7 @@ binds the detector to a platform-appropriate desktop notification sender.
5
5
  """
6
6
 
7
7
  import sys
8
+ from typing import Callable, Optional
8
9
 
9
10
 
10
11
  class CrossingDetector:
@@ -58,21 +59,37 @@ class UsageNotifier:
58
59
  ("weekly", "Weekly", "weekly_utilization"),
59
60
  )
60
61
 
61
- def __init__(self, config: dict, sender=None):
62
+ def __init__(
63
+ self,
64
+ config: dict,
65
+ sender: Optional[Callable[[str, str], None]] = None,
66
+ on_threshold: Optional[Callable[[str, float], None]] = None,
67
+ ):
62
68
  self.enabled = bool(config.get("notifications_enabled", True))
63
69
  thresholds = config.get("notify_thresholds", [0.75, 0.90])
64
70
  self.detector = CrossingDetector(thresholds)
65
71
  self._send = sender or _default_sender()
72
+ # Observer callback fired for every threshold crossing, used e.g.
73
+ # by the widget to dispatch a webhook. Fires independent of the
74
+ # ``enabled`` flag — webhooks are a separate opt-in pathway.
75
+ self._on_threshold = on_threshold
66
76
 
67
77
  def check_stats(self, stats) -> None:
68
- if not self.enabled:
69
- return
70
78
  for scope, label, attr in self.SCOPES:
71
79
  util = getattr(stats, attr, 0.0) or 0.0
72
- for t in self.detector.check(scope, util):
73
- pct_t = int(round(t * 100))
74
- pct_now = int(round(util * 100))
75
- self._send(
76
- f"Claude {label} usage at {pct_now}%",
77
- f"Crossed the {pct_t}% threshold.",
78
- )
80
+ crossings = self.detector.check(scope, util)
81
+ for t in crossings:
82
+ # Desktop notification (respects notifications_enabled)
83
+ if self.enabled:
84
+ pct_t = int(round(t * 100))
85
+ pct_now = int(round(util * 100))
86
+ self._send(
87
+ f"Claude {label} usage at {pct_now}%",
88
+ f"Crossed the {pct_t}% threshold.",
89
+ )
90
+ # Observer callback (independent of notifications_enabled)
91
+ if self._on_threshold is not None:
92
+ try:
93
+ self._on_threshold(scope, t)
94
+ except Exception:
95
+ pass
@@ -759,13 +759,21 @@ class ClaudeUsageTray:
759
759
  self.popup: UsagePopup = UsagePopup(config)
760
760
  self.overlay: UsageOverlay = UsageOverlay(config)
761
761
  self.overlay.show_all()
762
- self.notifier = UsageNotifier(config)
763
762
 
764
763
  # Webhook dispatcher — fires on threshold / daily / anomaly events.
765
764
  from claude_usage.webhooks import WebhookDispatcher
766
765
  self._webhooks = WebhookDispatcher(config.get("webhooks", {}))
767
766
  self._last_daily_report_date: str = ""
768
767
 
768
+ # Notifier must be constructed after _webhooks so its on_threshold
769
+ # callback can dispatch to the webhook.
770
+ self.notifier = UsageNotifier(
771
+ config,
772
+ on_threshold=lambda scope, t: self._webhooks.fire(
773
+ "threshold_crossed", {"scope": scope, "threshold": t},
774
+ ),
775
+ )
776
+
769
777
  # Optional: start localhost JSON API server for shell integrations.
770
778
  self._api_server = None
771
779
  if config.get("api_server_enabled"):
@@ -1032,13 +1032,21 @@ class ClaudeUsageTray(rumps.App):
1032
1032
  self.popup = UsagePopup()
1033
1033
  self.overlay = UsageOverlay(config)
1034
1034
  self.overlay.show_all()
1035
- self.notifier = UsageNotifier(config)
1036
1035
 
1037
1036
  # Webhook dispatcher — fires on threshold / daily / anomaly events.
1038
1037
  from claude_usage.webhooks import WebhookDispatcher
1039
1038
  self._webhooks = WebhookDispatcher(config.get("webhooks", {}))
1040
1039
  self._last_daily_report_date: str = ""
1041
1040
 
1041
+ # Notifier must be constructed after _webhooks so its on_threshold
1042
+ # callback can dispatch to the webhook.
1043
+ self.notifier = UsageNotifier(
1044
+ config,
1045
+ on_threshold=lambda scope, t: self._webhooks.fire(
1046
+ "threshold_crossed", {"scope": scope, "threshold": t},
1047
+ ),
1048
+ )
1049
+
1042
1050
  # Optional: start localhost JSON API server for shell integrations.
1043
1051
  self._api_server = None
1044
1052
  if config.get("api_server_enabled"):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: claude-usage-widget
3
- Version: 0.2.2
3
+ Version: 0.2.3
4
4
  Summary: Desktop widget and CLI that shows real-time Claude Code usage limits and cost.
5
5
  Author: Burak
6
6
  License: MIT
@@ -68,41 +68,54 @@ A desktop widget that displays your Claude Code usage limits in real time. Shows
68
68
 
69
69
  ## Installation
70
70
 
71
- ### Linux
71
+ ### Linux (pip — recommended)
72
72
 
73
73
  ```bash
74
- # 1. Install system dependencies (Ubuntu/Debian)
75
- sudo apt install python3-gi python3-gi-cairo python3-cairo gir1.2-ayatanaappindicator3-0.1
74
+ # 1. Install system GTK stack (one-time)
75
+ sudo apt install python3-gi python3-gi-cairo python3-cairo \
76
+ gir1.2-ayatanaappindicator3-0.1 gir1.2-notify-0.7 # Ubuntu/Debian
77
+ # Fedora: sudo dnf install python3-gobject python3-gobject-cairo libappindicator-gtk3 libnotify
78
+ # Arch: sudo pacman -S python-gobject python-cairo libappindicator-gtk3 libnotify
79
+
80
+ # 2. Install the widget itself
81
+ pip install --user --upgrade claude-usage-widget
76
82
 
77
- # Fedora
78
- sudo dnf install python3-gobject python3-gobject-cairo python3-cairo gtk3
83
+ # 3. Run
84
+ claude-usage # launches tray + OSD
85
+ claude-usage --version
86
+ ```
79
87
 
80
- # Arch
81
- sudo pacman -S python-gobject python-cairo gtk3 libappindicator-gtk3
88
+ GNOME users also need the [AppIndicator extension](https://extensions.gnome.org/extension/615/appindicator-support/) for the tray icon.
82
89
 
83
- # 2. Clone and run
90
+ ### Linux (from source)
91
+
92
+ ```bash
84
93
  git clone https://github.com/bozdemir/claude-usage-widget.git
85
94
  cd claude-usage-widget
86
95
  python3 main.py &
87
96
 
88
- # 3. Autostart on login (optional)
97
+ # Autostart on login (optional)
89
98
  ./install.sh
90
99
  ```
91
100
 
92
- ### macOS
101
+ ### macOS (Homebrew — recommended)
102
+
103
+ ```bash
104
+ brew tap bozdemir/tap
105
+ brew install claude-usage-widget
106
+ claude-usage # launches menu bar + OSD
107
+ claude-usage --version
108
+ ```
109
+
110
+ ### macOS (from source)
93
111
 
94
112
  ```bash
95
- # 1. Clone
96
113
  git clone https://github.com/bozdemir/claude-usage-widget.git
97
114
  cd claude-usage-widget
98
-
99
- # 2. Install Python dependencies
100
115
  pip3 install -r requirements-macos.txt
101
-
102
- # 3. Run
103
116
  python3 main.py
104
117
 
105
- # 4. Autostart on login (optional) -- installs a Launch Agent
118
+ # Autostart on login (optional) -- installs a Launch Agent
106
119
  ./install-macos.sh
107
120
  ```
108
121