diff options
| author | Danilo M. <danix@danix.xyz> | 2026-09-18 19:09:23 +0200 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-09-18 19:09:23 +0200 |
| commit | d975c14645554cfbe9ba1d8c9279f51bd8407673 (patch) | |
| tree | e5b60d21939ea02b4e2cb50a4342d071763083b1 /lib | |
| parent | 7fddddcd39bb250cd2653e130c8f7899d2d3f19c (diff) | |
| download | conky-theme-udt-d975c14645554cfbe9ba1d8c9279f51bd8407673.tar.gz conky-theme-udt-d975c14645554cfbe9ba1d8c9279f51bd8407673.zip | |
feat: add a title icon to every labelled card
Add card.ICON and a card.title helper that draws the glyph in the
highlight colour before the label, at the label's own size. The eight
labelled cards use it, in both the fit_unit width measurement and the
draw, so the icon cannot overrun a narrow cell. Clock (no label) and
weather (condition glyph already) are unchanged, and the no-data notice
titles stay text-only.
Codepoints were chosen against a rendered contact sheet, not fontconfig
alone, since a wrong codepoint draws a plausible neighbour.
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/card.lua | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/lib/card.lua b/lib/card.lua index 3c520b9..e3cb11e 100644 --- a/lib/card.lua +++ b/lib/card.lua @@ -118,6 +118,40 @@ function M.card(cr, rect, colors, pad) w = rect.w - pad * 2, h = rect.h - pad * 2 } end +-- Card title glyphs, all present in FONT_MONO (Inconsolata Nerd Font). +-- +-- Verified by rendering a contact sheet and looking at each one, not by +-- fontconfig alone: a missing glyph draws as an invisible blank and a wrong +-- codepoint as a plausible neighbour, so neither fails visibly. +M.ICON = { + system = '\u{F0EE0}', -- cpu-64-bit + gpu = '\u{F083E}', -- video-4k-box (no GPU glyph exists) + disks = '\u{F02CA}', -- harddisk + cache = '\u{F0ABA}', -- folder-clock + network = '\u{F0317}', -- lan + slackware = '\u{F318}', -- linux-slackware + breaktimer = '\u{F13AB}', -- timer + calendar = '\u{F0E17}', -- calendar-month +} + +-- The gap between a title's icon and its text. One constant so the measured +-- width and the drawn width cannot drift apart. +local TITLE_GAP = ' ' + +-- The full run a title occupies, for fit_unit to measure. Colour does not +-- affect width, so measuring icon and text as one string is exact. +function M.title_str(icon, text) return icon .. TITLE_GAP .. text end + +-- Draw a card title: the icon in `highlight`, the text in `label`, both at the +-- caller's current font. x is the left edge, y the baseline. +function M.title(cr, x, y, icon, text, colors) + M.rgba(cr, colors.highlight) + M.text(cr, x, y, icon) + x = x + M.advance(cr, icon .. TITLE_GAP) + M.rgba(cr, colors.label) + M.text(cr, x, y, text) +end + -- The no-data face: the card chrome with a named message in it. -- -- Every cached card draws this when its sampler has not run, so the board keeps |
