diff options
| author | Danilo M. <danix@danix.xyz> | 2026-09-17 13:15:31 +0200 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-09-17 13:15:31 +0200 |
| commit | 8e1baa72813fd93fc103b6d2d69753f952a24e3f (patch) | |
| tree | 73c1718e9ee692d38cf6c7428783a759d3623756 /widgets/weather.lua | |
| parent | 5b210415759bf0fbd605a5cee84a10450866530c (diff) | |
| download | conky-theme-udt-8e1baa72813fd93fc103b6d2d69753f952a24e3f.tar.gz conky-theme-udt-8e1baa72813fd93fc103b6d2d69753f952a24e3f.zip | |
feat: put every card's big number in the same place
Mirror the weather header so the glyph sits large on the left and the
temperature, city and condition run against the right edge, and move the
system card's CPU percentage onto its header line, right-aligned. All
big values now render at the card's right edge.
Diffstat (limited to 'widgets/weather.lua')
| -rw-r--r-- | widgets/weather.lua | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/widgets/weather.lua b/widgets/weather.lua index cd3e074..f50c6f1 100644 --- a/widgets/weather.lua +++ b/widgets/weather.lua @@ -123,23 +123,25 @@ function M.draw(cr, rect, colors) -- anyway, since the stat rows run edge to edge. local function clamp(v, lo, hi) return math.max(lo, math.min(hi, v)) end local temp_size = clamp(inner.w * 0.135, 40, 84) - local glyph_size = clamp(temp_size * 0.74, 30, 60) + local glyph_size = clamp(temp_size * 0.95, 38, 78) local label_size = clamp(inner.w * 0.030, 12, 19) local desc_size = clamp(inner.w * 0.038, 15, 24) local row_size = clamp(inner.w * 0.032, 13, 20) local row_step = row_size * 2.0 - -- Header: temperature and city against the left edge, condition glyph - -- against the right. text_right takes the RIGHT edge as its x, and measures - -- ink rather than advance, which is what you want for aligning to an edge. + -- Header, mirrored to match the other cards: the condition glyph large on + -- the left, the big temperature and the rest of the text against the right + -- edge. text_right takes the RIGHT edge as its x, and measures ink rather + -- than advance, which is what you want for aligning to an edge. local glyph = weather.icon(w.id, now, w.sunrise, w.sunset) card.font(cr, card.FONT_MONO, glyph_size, false) card.rgba(cr, colors.highlight) - card.text_right(cr, inner.x + inner.w, y + glyph_size * 0.95, glyph) + card.text(cr, inner.x, y + glyph_size * 0.95, glyph) card.font(cr, card.FONT_HEAVY, temp_size, false) card.rgba(cr, colors.body) - card.text(cr, inner.x, y + temp_size * 0.86, string.format('%d\u{00B0}', math.floor(w.temp + 0.5))) + card.text_right(cr, inner.x + inner.w, y + temp_size * 0.86, + string.format('%d\u{00B0}', math.floor(w.temp + 0.5))) card.font(cr, card.FONT_MONO, label_size, false) card.rgba(cr, colors.label) @@ -147,7 +149,7 @@ function M.draw(cr, rect, colors) if weather.is_stale(w.dt, now) then city = city .. ' stale ' .. weather.age_str(w.dt, now) end - card.text(cr, inner.x, y + temp_size * 1.28, city) + card.text_right(cr, inner.x + inner.w, y + temp_size * 1.28, city) -- Condition, in OWM's own words, first letter capitalised. card.font(cr, card.FONT_UI, desc_size, false) @@ -155,7 +157,7 @@ function M.draw(cr, rect, colors) local desc = w.description or '' desc = desc:sub(1, 1):upper() .. desc:sub(2) local dy = y + temp_size * 1.95 - card.text(cr, inner.x, dy, desc) + card.text_right(cr, inner.x + inner.w, dy, desc) -- Rule. local ry = dy + desc_size * 1.4 |
