From 96ac1ee65da31055704e0a14cafacc33914d7e86 Mon Sep 17 00:00:00 2001 From: "Danilo M." Date: Wed, 30 Sep 2026 19:56:48 +0200 Subject: perf(dashboard): draw at 0.1s only while the dashboard is visible Conky gives Lua no way to request one redraw, so a scroll showed up to 2s late. Pointer enter and leave, which Hyprland sends on every toggle of the special workspace, now switch conky_set_update_interval between 0.1s and the config's 2s. At that rate the CPU and network counters would sample over 0.1s windows and the chart would fill 20x faster, so both now sample through data.new_gate on the /proc/uptime clock, about every 2s, and redraw their last values in between. The samplers move to texeci: execi runs in the main loop and a 0.7s nvtable or an Immich download stalled the scroll. Measured: about 12% of one core while visible, 0.5% while hidden. Co-Authored-By: Claude Opus 5.5 --- dashboard.lua | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'dashboard.lua') diff --git a/dashboard.lua b/dashboard.lua index 18ddf80..1db0b6e 100644 --- a/dashboard.lua +++ b/dashboard.lua @@ -168,6 +168,17 @@ local function draw(cr, sw, sh, colors) end end +-- Draw rate follows visibility. The dashboard lives on a special workspace +-- and is hidden most of the time, so it idles at the config's update_interval +-- (2s) and draws at VISIBLE_INTERVAL while shown, which is what makes the wheel +-- scroll live: conky has no way for Lua to request a single redraw. +-- +-- Shown and hidden are the pointer entering and leaving the window, which +-- Hyprland sends on every toggle of the workspace. The pointer is on the +-- focused monitor, where the special workspace opens, so enter follows show. +local VISIBLE_INTERVAL = 0.1 +local hidden_interval = nil + -- Pointer events, handed to the widget whose cell is under the pointer, if it -- defines mouse(event, rect). Coordinates are window-relative, and the window -- is the whole surface, so they index the same grid the draw uses. @@ -175,6 +186,12 @@ end -- Wrapped like the draw: a fault here must not take conky down. Returning true -- tells conky the event was consumed. function conky_mouse(event) + if event.type == 'mouse_enter' or event.type == 'mouse_leave' then + hidden_interval = hidden_interval or conky_info.update_interval + conky_set_update_interval(event.type == 'mouse_enter' + and VISIBLE_INTERVAL or hidden_interval) + return false + end if conky_window == nil then return false end local sw, sh = conky_window.width, conky_window.height for _, entry in ipairs(layout) do -- cgit v1.2.3