diff options
| author | Danilo M. <danix@danix.xyz> | 2026-10-18 15:29:35 +0200 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-10-18 15:29:35 +0200 |
| commit | 48fa63ff5d0e12edf86db7f01def635aa0aaa9fb (patch) | |
| tree | 28bdd13bf12cf51464b01975ee4e9eef08596f85 /widgets | |
| parent | e81d0c6f7e975b1b98f1adf84299ba921093d100 (diff) | |
| download | conky-theme-udt-48fa63ff5d0e12edf86db7f01def635aa0aaa9fb.tar.gz conky-theme-udt-48fa63ff5d0e12edf86db7f01def635aa0aaa9fb.zip | |
fix(calendar): mark events past this week on the month grid
The sampler asked khal for 8 days only, so the grid never coloured an
event later in the month. Sample through the month's end instead, and
cut the event table back to the coming week with calendar_upcoming().
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'widgets')
| -rw-r--r-- | widgets/calendar.lua | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/widgets/calendar.lua b/widgets/calendar.lua index 11dcb63..5e08a7b 100644 --- a/widgets/calendar.lua +++ b/widgets/calendar.lua @@ -209,7 +209,10 @@ function M.draw(cr, rect, colors) local ey = grid_bottom + ev_size * 1.1 - if #cal.events == 0 then + -- The cache spans the month for the grid; the table is the week ahead. + local events = data.calendar_upcoming(cal.events, today, 8) + + if #events == 0 then card.font(cr, card.FONT_UI, ev_size, false) card.rgba(cr, colors.label, 0.8) card.text(cr, inner.x, ey, 'nothing this week') @@ -225,7 +228,7 @@ function M.draw(cr, rect, colors) -- 'all day' is wider than '13:00'. card.font(cr, card.FONT_MONO, ev_size, false) local time_w = 0 - for _, e in ipairs(cal.events) do + for _, e in ipairs(events) do local w = card.advance(cr, when(e)) if w > time_w then time_w = w end end @@ -253,16 +256,16 @@ function M.draw(cr, rect, colors) local probe = ey while probe <= floor_y do room = room + 1; probe = probe + ev_step end - local shown = #cal.events + local shown = #events -- The overflow line costs a row, so it is only worth taking when it reports -- more than the row it displaces. if room < shown then shown = (room >= 2) and (room - 1) or room end - local hidden = #cal.events - shown + local hidden = #events - shown for i = 1, shown do - local e = cal.events[i] + local e = events[i] if ey > floor_y then break end local colour = cal_colour(e.calendar, colors, cal.colors) |
