From 48fa63ff5d0e12edf86db7f01def635aa0aaa9fb Mon Sep 17 00:00:00 2001 From: "Danilo M." Date: Sun, 18 Oct 2026 15:29:35 +0200 Subject: 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 --- bin/calendar-sample.sh | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'bin') diff --git a/bin/calendar-sample.sh b/bin/calendar-sample.sh index af583f6..a0fb87e 100755 --- a/bin/calendar-sample.sh +++ b/bin/calendar-sample.sh @@ -45,9 +45,17 @@ trap 'rm -f "$TMP"' EXIT # 8d, not 7d: khal's range is exclusive of the final day in practice for # all-day events, and one extra day costs nothing but avoids a birthday # vanishing from the card on the morning it matters. +# +# The range runs to the end of the month when that is further out, because +# the month grid colours every day with an event, not just this week's. The +# widget cuts the event table back to the 8 days itself. khal's Nd covers day +# offsets 0..N-1, so the month's last day needs last - today + 1. +LAST=$(date -d "$(date +%Y-%m-01) +1 month -1 day" +%-d) +DAYS=$(( LAST - $(date +%-d) + 1 )) +[ "$DAYS" -lt 8 ] && DAYS=8 EVENTS=$(khal list --day-format '' \ --format '{start-date-long}|{start-time}|{end-time}|{calendar}|{title}' \ - --notstarted today 8d 2>/dev/null) + --notstarted today "${DAYS}d" 2>/dev/null) # khal's exit status is 0 even with no calendars configured, so emptiness is # not distinguishable from failure by status alone. The widget treats a missing -- cgit v1.2.3