icons

package
v0.3.12 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 5, 2026 License: MIT Imports: 24 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
const CustomPrefix = "cm"

CustomPrefix marks user-imported icons (sources/mod.rs CUSTOM_PREFIX).

View Source
const (

	// FormatVersion is stamped onto every emitted SVG via gpa:version.
	FormatVersion = 2
)
View Source
const IconsSubdir = "hicolor/scalable/actions"

IconsSubdir is where lys-shell's icons live below an icon root.

Variables

View Source
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.

View Source
var ErrHomeNotSet = errors.New("$HOME environment variable not set")

ErrHomeNotSet is HomeNotSet.

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

func DefaultPath() (string, error)

DefaultPath is $XDG_DATA_HOME/lys-shell/icons or ~/.local/share/lys-shell/icons; a relative XDG_DATA_HOME is ignored, as the XDG spec says.

func IOErrorString

func IOErrorString(err error) string

IOErrorString renders err the way Rust's std::io::Error displays: an OS error as "<strerror> (os error N)".

func List added in v0.2.0

func List(roots []string) ([]string, error)

List is every icon name the theme roots offer under hicolor/scalable/actions, where lys-shell's icons live (the user's registry, the packaged ones under a data dir's icons), deduplicated and sorted. A root without that directory offers none; one that cannot be read is an error naming it, returned alongside the names the other roots offer.

func ScanStrings

func ScanStrings(text string, into map[string]bool)

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

func ScanValue(v any, into map[string]bool)

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

func ToSymbolic(svg string) (string, bool)

ToSymbolic is transform::to_symbolic; false when nothing can be extracted.

Types

type DeleteError

type DeleteError struct {
	Name string
	Err  error
}

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

type DirectoryError struct {
	Path string
	Err  error
}

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

type FetchError struct {
	Slug   string
	Source string
	Status int
}

FetchError is a non-success HTTP status from the CDN.

func (*FetchError) Error

func (e *FetchError) Error() string

type HTTPError

type HTTPError struct{ Detail string }

HTTPError is a failed request.

func (*HTTPError) Error

func (e *HTTPError) Error() string

type InstallFailure

type InstallFailure struct {
	Slug  string
	Error string
}

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

type InvalidSVGError struct {
	Slug   string
	Reason string
}

InvalidSVGError is content usvg rejects, or one with no extractable geometry.

func (*InvalidSVGError) Error

func (e *InvalidSVGError) Error() string

type InvalidSourceError

type InvalidSourceError struct {
	Name      string
	Available string
}

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

func NewManager() (*Manager, error)

NewManager uses the default registry and HTTP client.

func NewManagerWith

func NewManagerWith(r *Registry, client *http.Client) *Manager

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

func (m *Manager) ImportLocal(path, name string) (string, error)

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

func (m *Manager) IsInstalled(name string) bool

IsInstalled reports <name>.svg in the icons directory.

func (*Manager) List

func (m *Manager) List() ([]string, error)

List is every installed icon name, the user's and the system's lys-shell roots', sorted (List over those roots).

func (*Manager) Registry

func (m *Manager) Registry() *Registry

Registry is the manager's registry.

func (*Manager) Remove

func (m *Manager) Remove(name string) error

Remove deletes <name>.svg from 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 ReadError

type ReadError struct {
	Path string
	Err  error
}

ReadError is an unreadable file.

func (*ReadError) Error

func (e *ReadError) Error() string

func (*ReadError) Unwrap

func (e *ReadError) Unwrap() error

type Registry

type Registry struct {
	// contains filtered or unexported fields
}

Registry locates lys-shell's icon theme directory.

func NewRegistry

func NewRegistry() (*Registry, error)

NewRegistry uses the default directory.

func RegistryAt

func RegistryAt(base string) *Registry

RegistryAt uses base as the theme root.

func (*Registry) BasePath

func (r *Registry) BasePath() string

BasePath is the theme root.

func (*Registry) EnsureSetup

func (r *Registry) EnsureSetup() error

EnsureSetup creates the directory tree and index.theme.

func (*Registry) IconsDir

func (r *Registry) IconsDir() string

IconsDir is <base>/hicolor/scalable/actions.

func (*Registry) IsValid

func (r *Registry) IsValid() bool

IsValid reports the icons dir and index.theme both present.

func (*Registry) ThemeSearchPaths

func (r *Registry) ThemeSearchPaths(existing []string) []string

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).

func (*Registry) Watch

func (r *Registry) Watch(onChange func()) (stop func(), err error)

Watch runs onChange after each burst of icons appearing in or leaving the icons directory (start_watcher), on the watcher's goroutine, until stop; once stop returns, onChange never runs again, so stop must not be called from onChange. The directory must exist (EnsureSetup).

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

func SourceByCLIName(name string) (Source, error)

SourceByCLIName is sources::from_cli_name.

func (Source) CDNURL

func (s Source) CDNURL(slug string) string

CDNURL is the icon's download URL.

func (Source) IconName

func (s Source) IconName(slug string) string

IconName is "<prefix>-<slug>".

func (Source) InstalledName

func (s Source) InstalledName(slug string) string

InstalledName is the name an installed icon goes by (and its file stem): "<prefix>-<slug>-symbolic".

type SyncFailure

type SyncFailure struct {
	Name  string
	Error string
}

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

type WriteError struct {
	Path string
	Err  error
}

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

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL