aboutsummaryrefslogtreecommitdiffstats
path: root/widgets
diff options
context:
space:
mode:
authorDanilo M. <danix@danix.xyz>2026-11-14 11:27:41 +0100
committerDanilo M. <danix@danix.xyz>2026-11-14 11:27:41 +0100
commitc39361726fa9cf1623d49ea1b9b2dd7e43f67622 (patch)
treef48bdef65dc66546e9b486a6379d2cd6515d1af4 /widgets
parent7ade0f07325d5fb92e530b6ec1bb8d4f9896be73 (diff)
downloadconky-theme-udt-c39361726fa9cf1623d49ea1b9b2dd7e43f67622.tar.gz
conky-theme-udt-c39361726fa9cf1623d49ea1b9b2dd7e43f67622.zip
feat(calendar): list due tasks from a task vdir beside the events
The sampler reads open VTODOs with a due date from ~/.local/share/tasks/<list>/*.ics (a vdirsyncer filesystem storage, override with UDT_TASKS_DIR) and writes them to the cache as ISO 'task' lines. The card merges them into the week's rows by date, with a checkbox before the title and an urgency colour: overdue critical, due today warning, later label. Overdue tasks stay until done, so they lead the table. Tasks never mark the month grid. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'widgets')
-rw-r--r--widgets/calendar.lua41
1 files changed, 35 insertions, 6 deletions
diff --git a/widgets/calendar.lua b/widgets/calendar.lua
index 5e08a7b..e8f2685 100644
--- a/widgets/calendar.lua
+++ b/widgets/calendar.lua
@@ -1,4 +1,5 @@
--- Calendar: the current month, and the week's appointments below it.
+-- Calendar: the current month, and the week's appointments and due tasks
+-- below it. Tasks never mark the grid: colour there means an appointment.
--
-- Events come from a cache file written by bin/calendar-sample.sh, because
-- conky's Lua cannot run a process and khal costs ~200ms of Python startup,
@@ -48,8 +49,25 @@ end
-- Day/month, no year: the grid above already names the month, and the window
-- is a week, so a year would be three characters of the row spent on the one
-- field that cannot vary.
+--
+-- A task with no due time shows its date alone: 'all day' would say it
+-- occupies the day, which a task does not.
local function when(e)
- return string.format('%02d/%02d %s', e.d, e.m, e.start or 'all day')
+ return string.format('%02d/%02d %s', e.d, e.m,
+ e.start or (e.task and '' or 'all day'))
+end
+
+-- A row's code colour. Events take their calendar's; tasks take urgency, in
+-- the board's own language: overdue `critical`, due today `warning`, later
+-- `label`. The checkbox before the title is what tells a task from an event,
+-- since `critical` is also a calendar colour.
+local function row_colour(e, today, colors, khal_colors)
+ if not e.task then return cal_colour(e.calendar, colors, khal_colors) end
+ local due = e.y * 10000 + e.m * 100 + e.d
+ local now = today[1] * 10000 + today[2] * 100 + today[3]
+ if due < now then return colors.critical end
+ if due == now then return colors.warning end
+ return colors.label
end
-- The legend: one coloured dot and name per calendar, along the card's bottom.
@@ -209,8 +227,9 @@ function M.draw(cr, rect, colors)
local ey = grid_bottom + ev_size * 1.1
- -- The cache spans the month for the grid; the table is the week ahead.
- local events = data.calendar_upcoming(cal.events, today, 8)
+ -- The cache spans the month for the grid; the table is the week ahead,
+ -- with open tasks due in it (and overdue ones) merged in by date.
+ local events = data.calendar_agenda(cal, today, 8)
if #events == 0 then
card.font(cr, card.FONT_UI, ev_size, false)
@@ -267,7 +286,7 @@ function M.draw(cr, rect, colors)
for i = 1, shown do
local e = events[i]
if ey > floor_y then break end
- local colour = cal_colour(e.calendar, colors, cal.colors)
+ local colour = row_colour(e, today, colors, cal.colors)
card.font(cr, card.FONT_MONO, ev_size, false)
card.rgba(cr, colour)
@@ -276,9 +295,19 @@ function M.draw(cr, rect, colors)
-- The title in the body colour, not the calendar's: colour-coding every
-- glyph in the row makes three calendars read as three unrelated cards.
-- The time carries the code, the title stays readable.
+ local tx, chars = title_x, title_chars
+ if e.task then
+ -- The checkbox in the row's urgency colour, from the mono face since
+ -- the UI face has no Nerd Font glyphs.
+ local icon = card.ICON.task .. ' '
+ card.font(cr, card.FONT_MONO, ev_size, false)
+ card.text(cr, tx, ey, icon)
+ tx = tx + card.advance(cr, icon)
+ chars = math.max(4, chars - 2)
+ end
card.font(cr, card.FONT_UI, ev_size, false)
card.rgba(cr, colors.value)
- card.text(cr, title_x, ey, card.truncate(e.title, title_chars))
+ card.text(cr, tx, ey, card.truncate(e.title, chars))
ey = ey + ev_step
end