master
4 Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
a9254fc70e |
Wake on click instantly instead of the next 0.5s tick
The main loop slept on time.sleep(event_deadline()), so a click sat in the datagram socket until the next 0.5s timer tick woke the loop. That added up to ~450ms of latency before the click affected state.json, on top of waybar's 1s re-poll. Replace the sleep with select() on the socket: select returns the moment a datagram arrives, so the loop drains and writes the click within milliseconds (measured 29ms) while still bounding idle sleep by the next timer deadline. Rotation cadence and click-during-fetch behavior are unchanged. The waybar custom-module interval stays 1: fractional intervals below 1s break custom modules (Waybar #4894 turns 0.5 into a 1ms busy loop), so the 0-1s re-poll is the floor and not safely tunable. |
||
|
|
09668a7c9a |
Fix popover: show all accounts with per-row bars and a dark window
The native tooltip never rendered. Two waybar quirks stacked: 1. custom/ocd had tooltip-format set. For a custom module with return-type json, a tooltip-format overrides the JSON tooltip field and waybar falls back to the label text (Waybar #3022). So the popover showed the single rotating account label instead of all accounts. Remove tooltip-format; waybar now uses the daemon's JSON tooltip field. 2. The daemon joined tooltip lines with newline. waybar custom modules break on newline (the tooltip vanishes; Waybar #3153). The wiki says to use carriage return instead. Switch the separator to \r. Reformat the tooltip so each limit (5h/1w/1m) is on its own row under the account, with a blank row between accounts for a bigger gap, as requested. Add a dark tooltip background. waybar scopes tooltip CSS globally (wiki / PR #4930): style all bar tooltips with the existing theme dark color @background/@foreground so the popover matches the bar instead of rendering backgroundless. |
||
|
|
c4647dda6b |
Fix hang on click and reconnect after daemon restart
Two root causes shared one symptom: the waybar module froze after a click and needed a waybar restart to recover. 1. oc-waybar-ctl used socat's UNIX-SENDTO, a bidirectional relay that can block on a datagram socket. waybar runs the click command on its per-module event thread and stops updating the module until the command returns, so a hung socat froze the module. Replace the socat/nc chain with a bounded python3 sendto (2s timeout). python3 is guaranteed present since the daemon needs it. 2. The daemon ran oc raw json with a blocking subprocess.run on the main loop, so a slow network fetch (up to 60s) stalled the 5s rotation and queued clicks. Move fetch_ocd to a worker thread; the main loop adopts the result when it lands and never blocks. Rotation and click draining stay live during a fetch. Reconnect after a daemon restart now works because the click helper no longer wedges waybar's event thread; the module's interval-1 cat re-reads state.json as soon as the new daemon rewrites it (verified: state.json returns within 1s). |
||
|
|
ea834a99a5 |
Initial commit: ocd waybar plugin
Daemon (scripts/ocd-waybar) polls {
"schema_version": 1,
"generated_at": "2026-07-30T01:29:37.918330160+00:00",
"accounts": [
{
"account": "legal",
"workspace": "wrk_01KBJFEAZV7G2FJBE1KAPRQSJN",
"fetched_at": "2026-07-30T01:27:49.014903087+00:00",
"status": "cached",
"limits": {
"usage_5h": {
"used": 0.0,
"total": 100.0,
"unit": "%",
"resets_at": "2026-07-30T06:27:49.014903087+00:00",
"status": "ok"
},
"usage_week": {
"used": 88.0,
"total": 100.0,
"unit": "%",
"resets_at": "2026-08-03T00:00:01.014903087+00:00",
"status": "ok"
},
"usage_month": {
"used": 94.0,
"total": 100.0,
"unit": "%",
"resets_at": "2026-08-21T22:07:23.014903087+00:00",
"status": "ok"
},
"next_update": null
},
"balance": {
"remaining": 0.0,
"unit": "$"
}
},
{
"account": "legal2",
"workspace": "wrk_01KQHV4ZP2SHZHTCTF0HW1BKHA",
"fetched_at": "2026-07-30T01:27:49.920803926+00:00",
"status": "cached",
"limits": {
"usage_5h": {
"used": 0.0,
"total": 100.0,
"unit": "%",
"resets_at": "2026-07-30T06:27:49.920803926+00:00",
"status": "ok"
},
"usage_week": {
"used": 100.0,
"total": 100.0,
"unit": "%",
"resets_at": "2026-08-03T00:00:00.920803926+00:00",
"status": "rate-limited"
},
"usage_month": {
"used": 90.0,
"total": 100.0,
"unit": "%",
"resets_at": "2026-08-23T18:01:33.920803926+00:00",
"status": "ok"
},
"next_update": null
},
"balance": {
"remaining": 0.0,
"unit": "$"
}
},
{
"account": "kllr560",
"workspace": "wrk_01KYJ5B4PM2EGR16ZDC0JTH2CC",
"fetched_at": "2026-07-30T01:27:50.791975864+00:00",
"status": "cached",
"limits": {
"usage_5h": {
"used": 0.0,
"total": 100.0,
"unit": "%",
"resets_at": "2026-07-30T06:27:50.791975864+00:00",
"status": "ok"
},
"usage_week": {
"used": 79.0,
"total": 100.0,
"unit": "%",
"resets_at": "2026-08-03T00:00:00.791975864+00:00",
"status": "ok"
},
"usage_month": {
"used": 39.0,
"total": 100.0,
"unit": "%",
"resets_at": "2026-08-27T16:10:15.791975864+00:00",
"status": "ok"
},
"next_update": null
},
"balance": {
"remaining": 0.0,
"unit": "$"
}
},
{
"account": "pj-vendee",
"workspace": "wrk_01KYNGQCX4XEM0KD3PWVVE636D",
"fetched_at": "2026-07-30T01:27:51.638144968+00:00",
"status": "cached",
"limits": {
"usage_5h": {
"used": 0.0,
"total": 100.0,
"unit": "%",
"resets_at": "2026-07-30T06:27:51.638144968+00:00",
"status": "ok"
},
"usage_week": {
"used": 40.0,
"total": 100.0,
"unit": "%",
"resets_at": "2026-08-03T00:00:00.638144968+00:00",
"status": "ok"
},
"usage_month": {
"used": 20.0,
"total": 100.0,
"unit": "%",
"resets_at": "2026-08-29T01:09:27.638144968+00:00",
"status": "ok"
},
"next_update": null
},
"balance": {
"remaining": 0.0,
"unit": "$"
}
},
{
"account": "iyaunalunarovell",
"workspace": "wrk_01KYNTSGXF7GFXMAMT36N3GH21",
"fetched_at": "2026-07-30T01:27:52.584601387+00:00",
"status": "cached",
"limits": {
"usage_5h": {
"used": 94.0,
"total": 100.0,
"unit": "%",
"resets_at": "2026-07-30T02:27:25.584601387+00:00",
"status": "ok"
},
"usage_week": {
"used": 99.0,
"total": 100.0,
"unit": "%",
"resets_at": "2026-08-03T00:00:00.584601387+00:00",
"status": "ok"
},
"usage_month": {
"used": 49.0,
"total": 100.0,
"unit": "%",
"resets_at": "2026-08-29T02:22:06.584601387+00:00",
"status": "ok"
},
"next_update": null
},
"balance": {
"remaining": 0.0,
"unit": "$"
}
},
{
"account": "balensiefenpiwihu2906",
"workspace": "wrk_01KYQNFP718WP7X9W7RXC2Q133",
"fetched_at": "2026-07-30T01:27:53.457572405+00:00",
"status": "cached",
"limits": {
"usage_5h": {
"used": 53.0,
"total": 100.0,
"unit": "%",
"resets_at": "2026-07-30T03:43:22.457572405+00:00",
"status": "ok"
},
"usage_week": {
"used": 21.0,
"total": 100.0,
"unit": "%",
"resets_at": "2026-08-03T00:00:00.457572405+00:00",
"status": "ok"
},
"usage_month": {
"used": 10.0,
"total": 100.0,
"unit": "%",
"resets_at": "2026-08-29T19:27:31.457572405+00:00",
"status": "ok"
},
"next_update": null
},
"balance": {
"remaining": 0.0,
"unit": "$"
}
}
]
} every 30s (no force
flags, so ocd cache/TTL stays in charge), runs a 5s account rotation
in config order, and supports right-click 1h lock. The waybar
custom/ocd module reads a state.json written by the daemon; hover
shows all accounts via the native tooltip. Bars are Pango background
spans (~50px) in the label and plain block chars in the tooltip, since
waybar 0.15.0 renders custom tooltips as plain text.
|