aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDanilo M. <danix@danix.xyz>2026-09-17 19:27:13 +0200
committerDanilo M. <danix@danix.xyz>2026-09-17 19:27:13 +0200
commitdddeee2d12207fd42a2930de14c8f0b368eede55 (patch)
tree1b8898ccccf8444ea122d4991258937c107cb039
parentf0790a43f2b7d94b3847135120bb92782eaa892d (diff)
downloadconky-theme-udt-dddeee2d12207fd42a2930de14c8f0b368eede55.tar.gz
conky-theme-udt-dddeee2d12207fd42a2930de14c8f0b368eede55.zip
feat: show free and total under each disk ring
Replaces the percentage, which the ring already draws as an angle. A number repeating it costs a row in a column about 75px wide. Free carries the threshold colour because it is the measured quantity; the total is fixed and stays in the plain value colour, so each column has one coloured number. The cache card adopts card.truncate in the same pass: it was slicing names by byte, which halves a multi-byte character. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
-rw-r--r--widgets/cache.lua6
-rw-r--r--widgets/disks.lua28
2 files changed, 25 insertions, 9 deletions
diff --git a/widgets/cache.lua b/widgets/cache.lua
index 0aeb016..af20347 100644
--- a/widgets/cache.lua
+++ b/widgets/cache.lua
@@ -42,9 +42,9 @@ function M.draw(cr, rect, colors)
local items = c.items or {}
local names = {}
for i, e in ipairs(items) do
- local name = e.name
- if #name > 18 then name = name:sub(1, 17) .. '\u{2026}' end
- names[i] = name
+ -- By character, not byte: a cache directory can carry an accented name and
+ -- a byte slice cuts one in half, which Cairo draws as a replacement box.
+ names[i] = card.truncate(e.name, 18)
end
local row_n = #items
diff --git a/widgets/disks.lua b/widgets/disks.lua
index c5fec1e..3b0f221 100644
--- a/widgets/disks.lua
+++ b/widgets/disks.lua
@@ -67,7 +67,9 @@ function M.draw(cr, rect, colors)
local n = #fs
local per_row = n
local cell_w = inner.w / per_row
- local r = math.min(cell_w * 0.34, avail_h * 0.30)
+ -- 0.27 rather than 0.30: two rows sit under each ring now, not one, and the
+ -- radius is what gives up the height.
+ local r = math.min(cell_w * 0.34, avail_h * 0.27)
if r >= 18 then
for i, e in ipairs(fs) do
@@ -104,12 +106,26 @@ function M.draw(cr, rect, colors)
card.text(cr, cx - sw_ / 2, cy + r * 0.55, sub)
end
- -- The percentage sits under the ring, in the threshold colour.
- card.font(cr, card.FONT_MONO, label_size, false)
+ -- Free on top, total beneath, both centred under the ring.
+ --
+ -- The percentage that used to sit here is gone: the ring already draws
+ -- it as an angle, and a number repeating it costs a row in a column
+ -- about 75px wide. Free carries the threshold colour because it is the
+ -- measured quantity; the total is fixed, so it stays in `value`. One
+ -- coloured number per column, as the rest of the board reads.
+ local free_size = label_size
+ local total_size = label_size * 0.88
+ card.font(cr, card.FONT_MONO, free_size, false)
card.rgba(cr, colour)
- local pct = string.format('%d%%', e.pct)
- local pw = card.measure(cr, pct)
- card.text(cr, cx - pw / 2, cy + r + label_size * 1.7, pct)
+ local free_txt = card.human(e.avail) .. ' free'
+ local fw = card.measure(cr, free_txt)
+ card.text(cr, cx - fw / 2, cy + r + free_size * 1.7, free_txt)
+
+ card.font(cr, card.FONT_MONO, total_size, false)
+ card.rgba(cr, colors.value)
+ local total_txt = card.human(e.size)
+ local tw = card.measure(cr, total_txt)
+ card.text(cr, cx - tw / 2, cy + r + free_size * 1.7 + total_size * 1.4, total_txt)
end
else
local step = label_size * 2.6