aboutsummaryrefslogtreecommitdiffstats
path: root/widgets/disks.lua
diff options
context:
space:
mode:
authorDanilo M. <danix@danix.xyz>2026-09-18 18:41:31 +0200
committerDanilo M. <danix@danix.xyz>2026-09-18 18:41:31 +0200
commit7fddddcd39bb250cd2653e130c8f7899d2d3f19c (patch)
treeca427df07676563853fb7f25f6ce4eb14e63a25b /widgets/disks.lua
parent37cabe2fea2f86d481516aae6ddaeb14bac2e64f (diff)
downloadconky-theme-udt-7fddddcd39bb250cd2653e130c8f7899d2d3f19c.tar.gz
conky-theme-udt-7fddddcd39bb250cd2653e130c8f7899d2d3f19c.zip
refactor: unify card no-data face and fluid sizing
Extract card.notice so every cached card's no-data state is one fluid, theme-consistent face instead of a copy per widget, and delete the fixed-size card.label it replaces. Derive weather's arc geometry from its band (pad, curve room, sun dot, time labels) instead of fixed pixels, and cap the arc at a proportion of the card's width rather than 240px. Derive disks' bar-fallback height and its address type from the card's own label scale. Standardise the big-value factor to 1.0 across the fit_unit cards and document the big-value colour rule and the disks headline exception.
Diffstat (limited to 'widgets/disks.lua')
-rw-r--r--widgets/disks.lua21
1 files changed, 10 insertions, 11 deletions
diff --git a/widgets/disks.lua b/widgets/disks.lua
index 3b0f221..fa97b50 100644
--- a/widgets/disks.lua
+++ b/widgets/disks.lua
@@ -43,20 +43,16 @@ function M.draw(cr, rect, colors)
local function clamp(v, lo, hi) return math.max(lo, math.min(hi, v)) end
local label_size = clamp(inner.w * 0.030, 10, 16)
- card.font(cr, card.FONT_MONO, label_size, false)
- card.rgba(cr, colors.label)
- card.text(cr, inner.x, inner.y + label_size, 'DISKS')
-
local fs = data.df_parse(data.slurp(CACHE) or '')
if #fs == 0 then
- card.rgba(cr, colors.label)
- card.font(cr, card.FONT_UI, label_size * 1.2, true)
- card.text(cr, inner.x, inner.y + label_size * 3.4, 'no disk data')
- card.font(cr, card.FONT_MONO, label_size, false)
- card.text(cr, inner.x, inner.y + label_size * 5, 'bin/disks-sample.sh')
+ card.notice(cr, inner, colors, 'DISKS', 'no disk data', 'bin/disks-sample.sh')
return
end
+ card.font(cr, card.FONT_MONO, label_size, false)
+ card.rgba(cr, colors.label)
+ card.text(cr, inner.x, inner.y + label_size, 'DISKS')
+
local top = inner.y + label_size * 2.2
local avail_h = (inner.y + inner.h) - top
@@ -100,7 +96,9 @@ function M.draw(cr, rect, colors)
-- The address, inside the ring beneath the glyph. Only the NFS shares
-- have one; the local mounts are identified by their icon alone.
if sub then
- card.font(cr, card.FONT_MONO, clamp(r * 0.20, 9, 12), false)
+ -- Tied to the card's own label scale rather than a fixed px floor, so
+ -- every piece of small mono text on the card tracks the same size.
+ card.font(cr, card.FONT_MONO, clamp(r * 0.20, label_size * 0.7, label_size), false)
card.rgba(cr, colors.label)
local sw_ = card.measure(cr, sub)
card.text(cr, cx - sw_ / 2, cy + r * 0.55, sub)
@@ -129,6 +127,7 @@ function M.draw(cr, rect, colors)
end
else
local step = label_size * 2.6
+ local bar_h = clamp(label_size * 0.5, 4, 8)
local ey = top + label_size
for _, e in ipairs(fs) do
if ey + step > inner.y + inner.h then break end
@@ -143,7 +142,7 @@ function M.draw(cr, rect, colors)
card.rgba(cr, colour)
card.text_right(cr, inner.x + inner.w, ey,
string.format('%s / %s', card.human(e.used), card.human(e.size)))
- card.bar(cr, inner.x, ey + 6, inner.w, 6, e.pct / 100, colour, colors)
+ card.bar(cr, inner.x, ey + label_size * 0.5, inner.w, bar_h, e.pct / 100, colour, colors)
ey = ey + step
end
end