Documentation
¶
Overview ¶
Package extract runs the external color extractor that feeds theming: wallust, matugen, or pywal over the theming monitor's wallpaper (crates/wayle-wallpaper/src/types/color_extractor).
lys-shell does not compute palettes itself. It invokes the configured tool with exactly the arguments (and, for wallust, exactly the generated config and template) the Rust shell does, so the tool writes the same palette to the same cache file:
matugen -> MatugenColorsPath (the tool's --json stdout, saved by lys-shell) wallust -> WallustColorsPath (written by wallust through the template) pywal -> PywalColorsPath (pywal's own ~/.cache/wal/colors.json)
Theme providers read those files (crates/wayle-styling palette_provider) and re-read them whenever the wallpaper service reports a finished extraction (wallpaper.Service.Extracted and the ColorsExtracted D-Bus signal).
Index ¶
- Constants
- func ColorsPath(t Tool) (string, bool, error)
- func Extract(ctx context.Context, cfg Config, image string) error
- func MatugenColorsPath() (string, error)
- func NativePalette(sample []material.ARGB, variant material.Variant, contrast float64, source int) []byte
- func PywalColorsPath() (string, error)
- func Variant(s config.MatugenScheme) (material.Variant, error)
- func WallpaperColorsPath() (string, error)
- func WallustColorsPath() (string, error)
- type CommandError
- type Config
- type FailedError
- type MatugenScheme
- type Native
- type PathError
- type Tool
- type WallustBackend
- type WallustColorspace
- type WallustPalette
Constants ¶
const SampleSide = 128
SampleSide is the longest side, in samples, of the grid a wallpaper is read at for native extraction: the quantizer's input is bounded by it whatever the wallpaper's resolution.
Variables ¶
This section is empty.
Functions ¶
func ColorsPath ¶
ColorsPath is the cache file the given tool leaves its palette in; false for None.
func Extract ¶
Extract runs the configured tool over image and leaves the palette in the tool's cache file. None is a no-op.
func MatugenColorsPath ¶
MatugenColorsPath is where lys-shell saves matugen's JSON output ($XDG_CACHE_HOME/lys-shell/matugen-colors.json); the lys-shell cache dir is created on demand.
func NativePalette ¶ added in v0.3.15
func NativePalette(sample []material.ARGB, variant material.Variant, contrast float64, source int) []byte
NativePalette is the matugen-shaped JSON of the light and dark schemes of the sample's seed: the source-th best seed the scorer ranks, or its last when it ranks fewer.
func PywalColorsPath ¶
PywalColorsPath is pywal's own output ($XDG_CACHE_HOME/wal/colors.json); nothing is created, pywal owns that directory.
func Variant ¶ added in v0.3.15
func Variant(s config.MatugenScheme) (material.Variant, error)
Variant is the Material variant a matugen scheme name stands for.
func WallpaperColorsPath ¶ added in v0.3.15
WallpaperColorsPath is where the wallpaper provider leaves its palette ($XDG_CACHE_HOME/lys-shell/wallpaper-colors.json); the lys-shell cache dir is created on demand.
func WallustColorsPath ¶
WallustColorsPath is the wallust template's target ($XDG_CACHE_HOME/lys-shell/wallust-colors.json); the lys-shell cache dir is created on demand.
Types ¶
type CommandError ¶
CommandError is a tool that could not be started (not installed, not executable): ColorExtractionCommandFailed.
func (*CommandError) Error ¶
func (e *CommandError) Error() string
func (*CommandError) Unwrap ¶
func (e *CommandError) Unwrap() error
type Config ¶
type Config struct {
Tool Tool
MatugenScheme MatugenScheme
MatugenContrast float64 // -1.0 to 1.0
MatugenSourceColor uint8
MatugenLight bool
WallustPalette WallustPalette
WallustSaturation uint8 // 0-100, 0 disables the boost
WallustCheckContrast bool
WallustBackend WallustBackend
WallustColorspace WallustColorspace
WallustApplyGlobally bool
PywalSaturation float64 // 0.0-1.0
PywalContrast float64 // 1.0-21.0
PywalLight bool
PywalApplyGlobally bool
}
Config is the tool and its parameters (ColorExtractorConfig). The ranged fields hold values the config loader already clamped to the schema ranges; MatugenSourceColor is clamped to 0-3 here, as the Rust extract does.
func FromConfig ¶
func FromConfig(c config.ColorExtractorConfig) Config
FromConfig is the extraction config the [styling] keys describe.
type FailedError ¶
FailedError is a tool that exited unsuccessfully; Stderr is its trimmed standard error (ColorExtractionFailed).
func (*FailedError) Error ¶
func (e *FailedError) Error() string
type MatugenScheme ¶
type MatugenScheme = config.MatugenScheme
MatugenScheme is the matugen color scheme.
type Native ¶ added in v0.3.15
type Native struct {
// contains filtered or unexported fields
}
Native computes Material You palettes from wallpaper samples in process and writes them, in matugen's JSON shape, to WallpaperColorsPath. It keeps the last few palettes by the sample's content hash, so a wallpaper set again is not quantized again. It is not safe for concurrent use; the wallpaper service serializes it.
func (*Native) Clear ¶ added in v0.3.15
Clear removes the wallpaper palette: no wallpaper is set, so the provider falls back to the configured palette.
type PathError ¶
PathError is a lys-shell data/cache path that could not be resolved or written (ConfigPathError).
type Tool ¶
type Tool uint8
Tool is the external program that extracts a palette from an image (ColorExtractor in crates/wayle-wallpaper/src/types/color_extractor). None disables extraction.
const ( Wallust Tool = iota Matugen Pywal None // Material is lys-shell's own Material You extraction, which reads // the decoded wallpaper instead of running a program. Material )
Extraction tools. Wallust is the Rust default.
func ParseTool ¶
ParseTool reads a tool name case-insensitively, accepting the Rust FromStr aliases "wal" (pywal) and "disabled" (none).
func ToolFor ¶
func ToolFor(p config.ThemeProvider) Tool
ToolFor is the extractor a theme provider needs (build_extractor_config): the static lys-shell provider extracts nothing.
type WallustBackend ¶
type WallustBackend = config.WallustBackend
WallustBackend is the wallust sampling backend.
type WallustColorspace ¶
type WallustColorspace = config.WallustColorspace
WallustColorspace is the wallust color space.
type WallustPalette ¶
type WallustPalette = config.WallustPalette
WallustPalette is the wallust palette mode.