diff options
Diffstat (limited to 'bin')
| -rwxr-xr-x | bin/calendar-sample.sh | 10 |
1 files changed, 9 insertions, 1 deletions
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 |
