diff options
| author | Danilo M. <danix@danix.xyz> | 2026-10-18 10:40:18 +0200 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-10-18 10:40:18 +0200 |
| commit | e54d9405dd818cd3ee7c203b8ec1d21713470904 (patch) | |
| tree | 5b7afeff3bcec5c79c9aee4c9a1d09bc610fe3eb /lib | |
| parent | 7f14e983c2ed73f69dbdd7bb155203a0762b814a (diff) | |
| download | conky-theme-udt-e54d9405dd818cd3ee7c203b8ec1d21713470904.tar.gz conky-theme-udt-e54d9405dd818cd3ee7c203b8ec1d21713470904.zip | |
feat: the cache and slackware cards move to quickshell
Both cards are now drawn by quickshell, so the conky copies go: the two
widgets, their samplers and texeci lines, their fixtures and icons, and
du_parse with human_bytes, which only the cache card used. kv_parse stays
for breaktimer; its test now runs on an inline string. README gains a
Samplers section listing what conky still schedules, and DESIGN.md's
examples point at the cards that remain. Their slots in the layout are
left open.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/card.lua | 4 | ||||
| -rw-r--r-- | lib/data.lua | 48 |
2 files changed, 4 insertions, 48 deletions
diff --git a/lib/card.lua b/lib/card.lua index 0a93c88..0869ce9 100644 --- a/lib/card.lua +++ b/lib/card.lua @@ -215,8 +215,6 @@ end -- fontconfig alone: a missing glyph draws as an invisible blank and a wrong -- codepoint as a plausible neighbour, so neither fails visibly. M.ICON = { - cache = '\u{F0ABA}', -- folder-clock - slackware = '\u{F318}', -- linux-slackware breaktimer = '\u{F13AB}', -- timer calendar = '\u{F0E17}', -- calendar-month immich = '\u{F02F9}', -- image-multiple @@ -315,7 +313,7 @@ end -- -- This counts codepoints, not rendered width, so it does not account for a -- double-width CJK glyph. That is the right trade here: the strings it cuts --- are cache directory names and hardware model strings. Measure with +-- are calendar titles and place names. Measure with -- M.measure when true rendered width matters. function M.truncate(s, limit) s = tostring(s or '') diff --git a/lib/data.lua b/lib/data.lua index 6b32f07..1b4c64f 100644 --- a/lib/data.lua +++ b/lib/data.lua @@ -16,55 +16,13 @@ function M.slurp(path) return s end --- Human-readable size to bytes: '1.1G' -> 1181116006. --- --- Needed because du -sh is what the sampler runs (its output is also what the --- card displays), and 'biggest' has to be decided numerically: sorted as --- strings, '245M' beats '1.1G'. -local SUFFIX = { K = 1024, M = 1024^2, G = 1024^3, T = 1024^4, P = 1024^5 } - -function M.human_bytes(s) - if type(s) ~= 'string' then return nil end - local n, suf = s:match('^%s*([%d%.]+)%s*([KMGTP]?)') - n = tonumber(n) - if not n then return nil end - return n * (SUFFIX[suf] or 1) -end - --- Parse `du -sh` output: the first line is the total, the rest are children --- already sorted largest-first by the sampler. Returns nil when there is --- nothing usable, so the widget can draw its "no data" state. -function M.du_parse(text) - if type(text) ~= 'string' or text == '' then return nil end - local lines = {} - for line in text:gmatch('[^\n]+') do lines[#lines + 1] = line end - if #lines == 0 then return nil end - - local function entry(line) - local label, path = line:match('^(%S+)%s+(.+)$') - if not label then return nil end - return { label = label, bytes = M.human_bytes(label) or 0, - name = path:match('([^/]+)/?$') or path, path = path } - end - - local total = entry(lines[1]) - if not total then return nil end - local items = {} - for i = 2, #lines do - local e = entry(lines[i]) - if e then items[#items + 1] = e end - end - return { total = total, items = items } -end - -- Parse 'key value' lines into a table of strings. -- --- Values stay strings and are converted by the caller. The sampler writes --- epochs as integers and the widget decides whether an age reads as hours or --- days; a parser that guessed would have to know that. +-- Values stay strings and are converted by the caller; a parser that guessed +-- types would have to know what each key means. -- -- Only the first space separates, so a value keeps its own spaces: --- 'version Slackware 15.0+' yields 'Slackware 15.0+', not 'Slackware'. +-- 'title Long break' yields 'Long break', not 'Long'. function M.kv_parse(text) local out = {} if type(text) ~= 'string' then return out end |
