cat: 1.2.0 — click popup panel with the cat and CPU % (#103)
Clicking the bar widget now toggles an attached panel showing the same cat glyph at panel size plus the CPU percentage, replacing the old notification. The widget publishes its visible state (glyph, cpu, color, pace) through the plugin's shared state store and the panel re-renders on each update, keeping the big cat frame-synced with the bar cat. Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Fable 5
parent
793249578c
commit
00da2cd291
+18
-1
@@ -100,10 +100,27 @@ local function resolveColor()
|
||||
return "secondary"
|
||||
end
|
||||
|
||||
-- The click panel (cat_panel.luau) runs in a separate runtime; it mirrors the
|
||||
-- bar cat from this shared-state snapshot, republished whenever the visible
|
||||
-- glyph, whole CPU percent, or color changes (so at most once per animation
|
||||
-- frame, and only on sample/theme changes while idle).
|
||||
local lastPublished = nil
|
||||
local function publishState(pace, glyph, color)
|
||||
local cpu = math.floor(cpuPercent)
|
||||
local key = `{glyph}|{cpu}|{color}|{pace}`
|
||||
if key == lastPublished then
|
||||
return
|
||||
end
|
||||
lastPublished = key
|
||||
noctalia.state.set("cat", { glyph = glyph, cpu = cpu, color = color, pace = pace })
|
||||
end
|
||||
|
||||
local function render(pace)
|
||||
local glyph = pace == "idle" and GLYPH_IDLE or RUN_GLYPHS[frameIndex]
|
||||
local color = resolveColor()
|
||||
|
||||
publishState(pace, glyph, color)
|
||||
|
||||
local children = {
|
||||
ui.label({ text = glyph, fontFamily = catFont, baseline = "inkCentered", fontSize = catSize, color = color }),
|
||||
}
|
||||
@@ -144,7 +161,7 @@ function update()
|
||||
end
|
||||
|
||||
function onClick()
|
||||
noctalia.notify(noctalia.tr("title"), `CPU {math.floor(cpuPercent)}%`)
|
||||
noctalia.togglePanel("dotnetrob/cat:panel")
|
||||
end
|
||||
|
||||
function onConfigChanged()
|
||||
|
||||
Reference in New Issue
Block a user