aboutsummaryrefslogtreecommitdiffstats
path: root/widgets/hourly.lua
diff options
context:
space:
mode:
authorDanilo M. <danix@danix.xyz>2026-10-18 14:45:35 +0200
committerDanilo M. <danix@danix.xyz>2026-10-18 14:45:35 +0200
commitb4451efb0f957d3cd3d9750f903899d8a87e15f3 (patch)
tree30ba3bd158f3b77404227edffb6eda8cf1c4309e /widgets/hourly.lua
parent1d8b815d10e33b53c4e7d3f2668b3529a6e11c22 (diff)
downloadconky-theme-udt-b4451efb0f957d3cd3d9750f903899d8a87e15f3.tar.gz
conky-theme-udt-b4451efb0f957d3cd3d9750f903899d8a87e15f3.zip
fix(weather cards): review fixes
Hour and day labels go through weather.clock, hourly clamps rain chance and caps at 24 hours, week widens the scale by min and max together and sizes the glyph apart from the text, details compass letters never exceed row text, now always hints at the fetcher. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Diffstat (limited to 'widgets/hourly.lua')
-rw-r--r--widgets/hourly.lua23
1 files changed, 13 insertions, 10 deletions
diff --git a/widgets/hourly.lua b/widgets/hourly.lua
index 9566823..82f7585 100644
--- a/widgets/hourly.lua
+++ b/widgets/hourly.lua
@@ -12,8 +12,8 @@ local M = {}
-- The band, top to bottom: glyph line, temperature line, curve, hour line.
-- Every third hour is labelled; all 24 shape the curve.
local function draw_curve(cr, x, y, w, h, colors, hours, S)
- local n = #hours
- local label = math.max(9, math.min(S * 0.30, h * 0.11))
+ local n = math.min(#hours, 24)
+ local label = math.max(9, math.min(h * 0.11, w / 8 * 0.22))
local glyph = label * 1.5
local slot = w / n
local function px(i) return x + (i - 0.5) * slot end
@@ -22,7 +22,8 @@ local function draw_curve(cr, x, y, w, h, colors, hours, S)
if base - top < label * 2 then return end -- no room: no curve beats a broken one
local lo, hi = math.huge, -math.huge
- for _, hr in ipairs(hours) do
+ for i = 1, n do
+ local hr = hours[i]
if hr.temp then lo, hi = math.min(lo, hr.temp), math.max(hi, hr.temp) end
end
if lo > hi then return end
@@ -31,10 +32,11 @@ local function draw_curve(cr, x, y, w, h, colors, hours, S)
local function py(t) return base - (base - top) * (0.15 + 0.7 * (t - lo) / span) end
-- Rain chance as bars rising from the baseline, under the curve.
- card.rgba(cr, colors.rule, 0.5)
- for i, hr in ipairs(hours) do
- if hr.precip and hr.precip > 0 then
- local bh = (base - top) * 0.5 * hr.precip / 100
+ card.rgba(cr, colors.value, 0.3)
+ for i = 1, n do
+ local p = math.min(hours[i].precip or 0, 100)
+ if p > 0 then
+ local bh = (base - top) * 0.5 * p / 100
cairo_rectangle(cr, px(i) - slot * 0.3, base - bh, slot * 0.6, bh)
end
end
@@ -50,7 +52,8 @@ local function draw_curve(cr, x, y, w, h, colors, hours, S)
card.rgba(cr, colors.highlight)
cairo_set_line_width(cr, math.max(1.5, label * 0.15))
local pen = false
- for i, hr in ipairs(hours) do
+ for i = 1, n do
+ local hr = hours[i]
if hr.temp then
if pen then cairo_line_to(cr, px(i), py(hr.temp))
else cairo_move_to(cr, px(i), py(hr.temp)) end
@@ -71,7 +74,7 @@ local function draw_curve(cr, x, y, w, h, colors, hours, S)
card.text_centre(cr, px(i), y + glyph + label * 1.3, weather.deg(hr.temp))
card.rgba(cr, colors.label)
card.text_centre(cr, px(i), y + h - label * 0.2,
- hr.t and os.date('%H', hr.t) or '--')
+ weather.clock(hr.t, '%H'))
end
end
@@ -85,7 +88,7 @@ function M.draw(cr, rect, colors)
-- hours[1] is the current hour, so the big value is the one after it.
local y, S = card.standard(cr, inner, colors, {
icon = card.ICON.hourly, title = 'NEXT 24H',
- big = weather.deg((w.hours[2] or {}).temp), share = 0.3,
+ big = weather.deg((w.hours[2] or {}).temp), share = 0.4,
})
draw_curve(cr, inner.x, y, inner.w, inner.y + inner.h - y, colors, w.hours, S)
end