diff options
| author | Danilo M. <danix@danix.xyz> | 2026-09-29 13:33:14 +0200 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-09-29 13:33:14 +0200 |
| commit | 9624351d80ace747d3117fb22d6cbd00fce3eedf (patch) | |
| tree | f9adc0a04445718d2d2b5e1b659b00fb8373c73c /lib/data.lua | |
| parent | 272c5732b0bc932749f0e771de51ee49f6cebe5b (diff) | |
| download | conky-theme-udt-9624351d80ace747d3117fb22d6cbd00fce3eedf.tar.gz conky-theme-udt-9624351d80ace747d3117fb22d6cbd00fce3eedf.zip | |
feat: add an Immich memories card with click and scroll
A centred card showing today's "N years ago" photos from Immich, one at
a time on a 30-second rotation, with when each was taken and where.
bin/immich-fetch.sh runs from conky's execi every 30 minutes: it asks
/api/memories for today, converts each preview to PNG (Cairo loads
nothing else) and writes an index with the year, local capture time and
place. The place needs the key's asset.read permission and reads '--'
without it. The key lives in ~/.config/udt/immich.env, like the weather
key, because a GPG-backed store would raise a pinentry unattended.
The dashboard now registers lua_mouse_hook and hands pointer events to
the widget under the pointer. On this card, scrolling steps through the
photos and a left click opens the photo in Immich's web UI and hides the
dashboard so the browser is not stuck beneath it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'lib/data.lua')
| -rw-r--r-- | lib/data.lua | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/lib/data.lua b/lib/data.lua index 8e60d6d..1173fce 100644 --- a/lib/data.lua +++ b/lib/data.lua @@ -591,4 +591,41 @@ function M.breaktimer_parse(text) return out end +-- The Immich memories index written by bin/immich-fetch.sh. +-- +-- Returns a list of { id, year, taken = { y, m, d, H, M }, place }, plus +-- .url, the server's address for a click-through, or nil when +-- the index is absent or carries no 'generated' key. nil means "the fetch never +-- ran"; an empty list means "no memories today", which the card names +-- differently. `place` is nil when the key lacks asset.read or the photo has no +-- location, so the card can print '--'. +function M.immich_parse(text) + if type(text) ~= 'string' then return nil end + local out, generated = {}, false + for line in text:gmatch('[^\n]+') do + local kind, rest = line:match('^(%S+)%s+(.*)$') + if kind == 'generated' then + generated = true + elseif kind == 'url' then + out.url = rest + elseif kind == 'photo' then + -- The place is last and takes the rest of the line, so a pipe in a + -- place name cannot shift a field. + local id, year, taken, place = rest:match('^([^|]+)|(%d*)|([^|]*)|(.*)$') + if id then + local y, m, d, H, Mi = taken:match('^(%d+)-(%d+)-(%d+)T(%d+):(%d+)') + out[#out + 1] = { + id = id, + year = tonumber(year), + taken = y and { tonumber(y), tonumber(m), tonumber(d), + tonumber(H), tonumber(Mi) } or nil, + place = place ~= '' and place or nil, + } + end + end + end + if not generated then return nil end + return out +end + return M |
