Documentation
¶
Overview ¶
Package icons ports crates/wayle-icons: the icon sources (Tabler, Simple Icons, Material, Lucide), fetching from their CDNs, the SVG to GTK-symbolic transform, local imports, the on-disk icon directory, format migration, and the config-driven sync behind `lys-shell icons`.
Index ¶
- Constants
- Variables
- func AllPrefixes() []string
- func DefaultPath() (string, error)
- func IOErrorString(err error) string
- func ScanStrings(text string, into map[string]bool)
- func ScanValue(v any, into map[string]bool)
- func SystemIconPaths() []string
- func ToSymbolic(svg string) (string, bool)
- type DeleteError
- type DirectoryError
- type FetchError
- type HTTPError
- type InstallFailure
- type InstallResult
- type InvalidIconNameError
- type InvalidSVGError
- type InvalidSourceError
- type Manager
- func (m *Manager) ImportDir(dir string) (InstallResult, error)
- func (m *Manager) ImportLocal(path, name string) (string, error)
- func (m *Manager) Install(ctx context.Context, source Source, slugs []string) (InstallResult, error)
- func (m *Manager) IsInstalled(name string) bool
- func (m *Manager) List() []string
- func (m *Manager) Registry() *Registry
- func (m *Manager) Remove(name string) error
- type MigrationReport
- type MissingIcon
- type NotFoundError
- type ReadError
- type Registry
- type Source
- type SyncFailure
- type SyncSummary
- type WriteError
Constants ¶
const CustomPrefix = "cm"
CustomPrefix marks user-imported icons (sources/mod.rs CUSTOM_PREFIX).
const (
// FormatVersion is stamped onto every emitted SVG via gpa:version.
FormatVersion = 2
)
Variables ¶
var ( Tabler = Source{ DisplayName: "Tabler Icons (Outline)", CLIName: "tabler", Prefix: "tb", Description: "UI icons with outline/stroke style (home, settings, bell)", Website: "https://tabler.io/icons", // contains filtered or unexported fields } TablerFilled = Source{ DisplayName: "Tabler Icons (Filled)", CLIName: "tabler-filled", Prefix: "tbf", Description: "UI icons with solid/filled style (home, settings, bell)", Website: "https://tabler.io/icons", // contains filtered or unexported fields } SimpleIcons = Source{ DisplayName: "Simple Icons", CLIName: "simple-icons", Prefix: "si", Description: "Brand and app logos (firefox, spotify, github)", Website: "https://simpleicons.org", // contains filtered or unexported fields } Material = Source{ DisplayName: "Material Design", CLIName: "material", Prefix: "md", Description: "Google Material Design icons", Website: "https://fonts.google.com/icons", // contains filtered or unexported fields } Lucide = Source{ DisplayName: "Lucide Icons", CLIName: "lucide", Prefix: "ld", Description: "Alternative UI icons, Feather fork (home, settings, bell)", Website: "https://lucide.dev/icons", // contains filtered or unexported fields } )
The sources, one per CDN icon set.
var ErrHomeNotSet = errors.New("$HOME environment variable not set")
ErrHomeNotSet is HomeNotSet.
var Sources = []Source{Tabler, TablerFilled, SimpleIcons, Material, Lucide}
Sources are all sources in sources::all order.
Functions ¶
func AllPrefixes ¶
func AllPrefixes() []string
AllPrefixes are the source prefixes plus the custom one.
func DefaultPath ¶
DefaultPath is $XDG_DATA_HOME/lys-shell/icons or ~/.local/share/lys-shell/icons. As in Rust, a set-but-empty XDG_DATA_HOME is taken as given.
func IOErrorString ¶
IOErrorString renders err the way Rust's std::io::Error displays: an OS error as "<strerror> (os error N)".
func ScanStrings ¶
ScanStrings adds every icon name found in text to into: text is split on characters that cannot be in an icon name and each chunk shaped like <known-prefix>-<slug>-symbolic is kept (scan_string).
func ScanValue ¶
ScanValue walks a config value in the parsed shape (config.Service Value: map[string]any tables, []any arrays) and scans every string leaf (walk_value).
func SystemIconPaths ¶
func SystemIconPaths() []string
SystemIconPaths are the existing <XDG_DATA_DIRS>/lys-shell/icons roots, then /usr/share/lys-shell/icons.
func ToSymbolic ¶
ToSymbolic is transform::to_symbolic; false when nothing can be extracted.
Types ¶
type DeleteError ¶
DeleteError is an icon that could not be removed.
func (*DeleteError) Error ¶
func (e *DeleteError) Error() string
func (*DeleteError) Unwrap ¶
func (e *DeleteError) Unwrap() error
type DirectoryError ¶
DirectoryError is an icon directory that could not be created.
func (*DirectoryError) Error ¶
func (e *DirectoryError) Error() string
func (*DirectoryError) Unwrap ¶
func (e *DirectoryError) Unwrap() error
type FetchError ¶
FetchError is a non-success HTTP status from the CDN.
func (*FetchError) Error ¶
func (e *FetchError) Error() string
type InstallFailure ¶
InstallFailure is one icon that did not install.
type InstallResult ¶
type InstallResult struct {
Installed []string
Failed []InstallFailure
}
InstallResult is a batch outcome.
type InvalidIconNameError ¶
type InvalidIconNameError struct{ Name string }
InvalidIconNameError is a name that would escape the icons directory.
func (*InvalidIconNameError) Error ¶
func (e *InvalidIconNameError) Error() string
type InvalidSVGError ¶
InvalidSVGError is content usvg rejects, or one with no extractable geometry.
func (*InvalidSVGError) Error ¶
func (e *InvalidSVGError) Error() string
type InvalidSourceError ¶
InvalidSourceError is an unknown source name.
func (*InvalidSourceError) Error ¶
func (e *InvalidSourceError) Error() string
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager installs and removes icons under a registry.
func NewManager ¶
NewManager uses the default registry and HTTP client.
func NewManagerWith ¶
NewManagerWith uses the given registry and client.
func (*Manager) ImportDir ¶
func (m *Manager) ImportDir(dir string) (InstallResult, error)
ImportDir imports every *.svg in dir, keeping names that carry a known prefix and adding cm- to the rest.
func (*Manager) ImportLocal ¶
ImportLocal imports one SVG as cm-<name>-symbolic.
func (*Manager) Install ¶
func (m *Manager) Install(ctx context.Context, source Source, slugs []string) (InstallResult, error)
Install fetches slugs from source concurrently; per-icon failures are collected, and only an uncreatable icons directory is an error.
func (*Manager) IsInstalled ¶
IsInstalled reports <name>.svg in the icons directory.
type MigrationReport ¶
type MigrationReport struct {
Migrated, Skipped, Failed int
}
MigrationReport counts one pass.
func Migrate ¶
func Migrate(dir string) MigrationReport
Migrate rewrites every stale SVG in dir. It is a no-op when dir is missing or unwritable or the sentinel is current; per-file failures are logged, counted, and keep the sentinel from being written.
type MissingIcon ¶
type MissingIcon struct {
Name string
// Source is the CLI name of the source to fetch from; empty for a
// user-imported cm- icon, which cannot be fetched.
Source string
Slug string
}
MissingIcon is a referenced icon not on disk.
func FindMissing ¶
func FindMissing(referenced, installed map[string]bool) []MissingIcon
FindMissing is find_missing: the referenced names not installed that classify, in name order.
type NotFoundError ¶
type NotFoundError struct{ Name string }
NotFoundError is a missing icon or path.
func (*NotFoundError) Error ¶
func (e *NotFoundError) Error() string
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry locates lys-shell's icon theme directory.
func (*Registry) EnsureSetup ¶
EnsureSetup creates the directory tree and index.theme.
func (*Registry) ThemeSearchPaths ¶
ThemeSearchPaths is refresh_gtk_theme's icon search path: the user root first, then each system root, then the rest of existing in its order (without those roots, so a refresh never duplicates them).
type Source ¶
type Source struct {
DisplayName string
CLIName string
Prefix string
Description string
Website string
// contains filtered or unexported fields
}
Source is one icon CDN (sources/mod.rs's IconSource).
func SourceByCLIName ¶
SourceByCLIName is sources::from_cli_name.
func (Source) InstalledName ¶
InstalledName is the name an installed icon goes by (and its file stem): "<prefix>-<slug>-symbolic".
type SyncFailure ¶
SyncFailure is one icon that errored, as "<source>/<slug>".
type SyncSummary ¶
type SyncSummary struct {
Installed []string
Failed []SyncFailure
Skipped []string
}
SyncSummary is a sync outcome.
func InstallMissing ¶
func InstallMissing(ctx context.Context, missing []MissingIcon, m *Manager) SyncSummary
InstallMissing installs every fetchable icon, one batch per source in source-name order; cm- icons are skipped.
type WriteError ¶
WriteError is an icon that could not be written.
func (*WriteError) Error ¶
func (e *WriteError) Error() string
func (*WriteError) Unwrap ¶
func (e *WriteError) Unwrap() error
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package icontest serves icon CDNs without the network, for tests of what installs icons.
|
Package icontest serves icon CDNs without the network, for tests of what installs icons. |
|
Package skpath is a port of the parts of tiny-skia-path 0.11 (Skia's SkPath, SkStroke and SkDashPath) the icon transform needs: path building, affine transforms, stroking into fill outlines, and dashing.
|
Package skpath is a port of the parts of tiny-skia-path 0.11 (Skia's SkPath, SkStroke and SkDashPath) the icon transform needs: path building, affine transforms, stroking into fill outlines, and dashing. |
|
Package usvg is a port of the subset of usvg 0.46 (with svgtypes, simplecss and kurbo's arc code) that turns an SVG document into the tree of groups and paths the icon transform walks: element and attribute resolution (presentation attributes, CSS, style, inherit), use/switch/nested svg expansion, markers, shapes to paths, and fill/stroke resolution.
|
Package usvg is a port of the subset of usvg 0.46 (with svgtypes, simplecss and kurbo's arc code) that turns an SVG document into the tree of groups and paths the icon transform walks: element and attribute resolution (presentation attributes, CSS, style, inherit), use/switch/nested svg expansion, markers, shapes to paths, and fill/stroke resolution. |