Icons
Lookup
lys-lib's icons implements the freedesktop icon theme spec in pure Go:
index.themeparsing:Inherits,Directories/ScaledDirectories, and per-directorySize,Type,MinSize,MaxSize,ThresholdandScale;- the spec's lookup: exact size, then nearest size, along the inheritance chain with hicolor last, then the unthemed base directories;
-symbolicname fallback;- a raster cache keyed by name, logical size and scale;
- a last tier of bundled Lucide icons (ISC) that common freedesktop names such as
document-save-symbolicmap onto, so stock chrome draws without an installed theme. An installed theme always wins.
Programs that draw icons without widgets use lys-lib's icontheme package.
widget.Icon
| Function | Does |
|---|---|
NewIcon(ic) | an icon from a caller-made *render.Icon |
NewThemeIcon(name, size) | a theme icon |
NewThemeIconFallback(name, size) | a theme icon that falls back to dash-shortened names (a-b-c, a-b, a) |
NewFileIcon(path, size) | a PNG, SVG or SVGZ file |
NewSVGIcon(svg, size) | embedded SVG bytes |
ThemeIconExists(name) | whether a theme name resolves |
SetIconSearchPaths(paths) | replaces the base directories; nil restores the XDG default |
SetIconNamespace(dir, prefixes) | serves names with these prefixes from dir without walking the theme chain |
RefreshIcons() | forgets resolved icons, picking up installs and removals |
PreloadThemeIcon, ThemeIconPreloaded | decode ahead of the first paint |
Icons rasterize at the device scale, fractional included. A paint never reads or decodes: it draws the decoded raster (or the nearest decoded scale) and requests a decode off the loop (Threading).
Symbolic recolouring
Symbolic sources are -symbolic theme files and SVGs that paint with currentColor. Recolouring is a mask pass: each pixel keeps its alpha and takes the tint colour, so anti-aliasing and fill-opacity carry over. Ink comes out in one flat colour; multi-colour art becomes monochrome.
A symbolic icon takes the stylesheet color, else the theme accent. SetTint pins a colour (zero unpins). Non-symbolic icons keep their colours unless a tint is pinned. Icons with the same tint share one raster.
Animated icons
A GTK symbolic icon with states (gpa:version='1', gpa:state-names, and per-path gpa:states, gpa:transition-* and gpa:animation-*) decodes as an animated icon. SetIconState(name) moves the widget to a state by name or number: paths leaving it play their out transitions, the change lands, then paths entering it play their in transitions and start their automatic animations, as GTK sequences them. IconStates() lists the states once the icon is decoded.
| Behaviour | Rule |
|---|---|
| Cost | each path is rasterized once per size and scale; draw-on steps are cached; a frame only blends masks |
| Frames | requested only while the icon is on screen and moving |
| Reduced motion | the new state lands at once and loops rest whole |
| Re-rasterization | a new scale or tint keeps the state and its timeline |
| Name change | SetThemeName starts over in the new icon's initial state |
| Plain icons | ignore the state |
| Unknown state | surfaces through Err |
| Morph | gpa:transition-type='morph' plays GTK's blur-and-threshold filter, its steps cached like draw-on steps |
| Attachments | a path with gpa:attach-to rides its target's drawn end at gpa:attach-pos, turned along it; a missing or ambiguous id fails the decode by name |
lys-shell's bar icons are such icons: just desktop::generate builds them from Lucide's strokes, one per module.
Theme changes
An Application starts with gtk-icon-theme-name from GTK's settings.ini and follows the portal's org.gnome.desktop.interface icon-theme setting live. A change swaps the theme, drops cached rasters and repaints icons on the next frame. An empty setting keeps the current theme and logs a Warn. The palette is not affected.