diff options
Diffstat (limited to 'widgets/disks.lua')
| -rw-r--r-- | widgets/disks.lua | 21 |
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 |
