Documentation
¶
Overview ¶
Package wallpaper ports crates/wayle-wallpaper: per-monitor wallpaper state, fit modes, directory cycling (sequential or shuffled, shared or per monitor, rescanned on directory changes), color extraction for theming, and the dev.stubbe.lys.Wallpaper1 D-Bus interface the `lys-shell wallpaper` CLI drives.
The service only tracks state; the shell renders it (shell/wallpaper) by subscribing to Changes and reading Monitors. The shell also feeds it the outputs it sees (RegisterMonitor/UnregisterMonitor), where the Rust service ran a second Wayland connection of its own for that.
Index ¶
- Constants
- Variables
- func Export(conn *dbus.Conn, svc *Service) (func(), error)
- func PickerImages(dirs []string) ([]string, error)
- func ScanImages(directory string) ([]string, error)
- type Client
- func (c *Client) Close() error
- func (c *Client) ExtractColors(ctx context.Context) error
- func (c *Client) GetFitMode(ctx context.Context, monitor string) (string, error)
- func (c *Client) GetIsCycling(ctx context.Context) (bool, error)
- func (c *Client) ListMonitors(ctx context.Context) ([]string, error)
- func (c *Client) Next(ctx context.Context) error
- func (c *Client) Previous(ctx context.Context) error
- func (c *Client) SetFitMode(ctx context.Context, mode, monitor string) error
- func (c *Client) SetThemingMonitor(ctx context.Context, monitor string) error
- func (c *Client) SetWallpaper(ctx context.Context, path, monitor string) error
- func (c *Client) StartCycling(ctx context.Context, directory string, intervalSecs uint32, mode string) error
- func (c *Client) StopCycling(ctx context.Context) error
- func (c *Client) WallpaperForMonitor(ctx context.Context, monitor string) (string, error)
- type Cycling
- type CyclingMode
- type Daemon
- func (d *Daemon) ExtractColors() *dbus.Error
- func (d *Daemon) GetFitMode(monitor string) (string, *dbus.Error)
- func (d *Daemon) GetIsCycling() (bool, *dbus.Error)
- func (d *Daemon) ListMonitors() ([]string, *dbus.Error)
- func (d *Daemon) Next() *dbus.Error
- func (d *Daemon) Previous() *dbus.Error
- func (d *Daemon) RegisterMonitor(monitor string) *dbus.Error
- func (d *Daemon) SetFitMode(mode, monitor string) *dbus.Error
- func (d *Daemon) SetThemingMonitor(monitor string) *dbus.Error
- func (d *Daemon) SetWallpaper(path, monitor string) *dbus.Error
- func (d *Daemon) StartCycling(directory string, intervalSecs uint32, mode string) *dbus.Error
- func (d *Daemon) StopCycling() *dbus.Error
- func (d *Daemon) UnregisterMonitor(monitor string) *dbus.Error
- func (d *Daemon) WallpaperForMonitor(monitor string) (string, *dbus.Error)
- type DirectoryNotFoundError
- type FitMode
- type ImageNotFoundError
- type MonitorState
- type NoImagesFoundError
- type Options
- type Sampler
- type Service
- func (s *Service) Advance()
- func (s *Service) Changes() (<-chan struct{}, func())
- func (s *Service) CyclingConfig() *Cycling
- func (s *Service) EndPreview()
- func (s *Service) ExtractColors(ctx context.Context) error
- func (s *Service) Extracted() (<-chan struct{}, func())
- func (s *Service) FitModeOf(monitor string) (FitMode, bool)
- func (s *Service) MonitorNames() []string
- func (s *Service) Monitors() map[string]MonitorState
- func (s *Service) RegisterMonitor(monitor string)
- func (s *Service) Rewind()
- func (s *Service) Run(ctx context.Context)
- func (s *Service) SetCyclingInterval(interval time.Duration)
- func (s *Service) SetExtractor(cfg extract.Config)
- func (s *Service) SetFitMode(mode FitMode, monitor string)
- func (s *Service) SetPreview(path, monitor string) error
- func (s *Service) SetSharedCycle(shared bool)
- func (s *Service) SetThemingMonitor(monitor string)
- func (s *Service) SetWallpaper(path, monitor string) error
- func (s *Service) StartCycling(directory string, interval time.Duration, mode CyclingMode) error
- func (s *Service) StopCycling()
- func (s *Service) ThemingMonitor() string
- func (s *Service) UnregisterMonitor(monitor string)
- func (s *Service) Wallpaper(monitor string) (string, bool)
Constants ¶
const ( ServiceName = "dev.stubbe.lys.Wallpaper1" ServicePath = dbus.ObjectPath("/dev/stubbe/lys/Wallpaper") Interface = "dev.stubbe.lys.Wallpaper1" )
D-Bus identity (dbus/mod.rs, dbus.md).
const ( FitFill = config.FitFill FitFit = config.FitFit FitCenter = config.FitCenter FitStretch = config.FitStretch )
Fit modes; Fill is the default.
const ( Sequential = config.CyclingSequential Shuffle = config.CyclingShuffle )
Cycling modes; Sequential is the default.
Variables ¶
var ColorsExtracted = dbusx.NewSignal[struct{}](Interface, "ColorsExtracted")
ColorsExtracted is the signal the service sends from ServicePath each time an extraction finished.
var SupportedExtensions = []string{
"png", "jpg", "jpeg", "gif", "bmp", "tga", "tiff", "webp", "pnm", "farbfeld", "svg", "jxl", "avif",
}
SupportedExtensions are the image extensions a cycling directory scan picks up, matched case-insensitively (SUPPORTED_EXTENSIONS).
Functions ¶
func Export ¶
Export exports the object, its read-only properties, and introspection, requests the well-known name, and forwards every finished extraction as the ColorsExtracted signal. The returned function releases the name and stops the forwarding.
func PickerImages ¶
PickerImages lists the supported images of every directory, sorted by path and each once. A directory that does not exist has none; one that cannot be read is skipped with its error returned.
func ScanImages ¶
ScanImages lists the directory's entries with a supported extension (scan_directory_for_images); like the Rust scan it does not look at the entry type, so a directory named x.png is listed too.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client drives a running daemon (the WallpaperProxy the CLI uses).
func (*Client) ExtractColors ¶
ExtractColors re-runs color extraction.
func (*Client) GetFitMode ¶
GetFitMode reads a monitor's fit mode.
func (*Client) GetIsCycling ¶
GetIsCycling reads whether cycling is active.
func (*Client) ListMonitors ¶
ListMonitors lists the registered monitors.
func (*Client) SetFitMode ¶
SetFitMode sets the fit mode on monitor ("" for all).
func (*Client) SetThemingMonitor ¶
SetThemingMonitor picks the theming monitor ("" for the default).
func (*Client) SetWallpaper ¶
SetWallpaper sets path on monitor ("" for all).
func (*Client) StartCycling ¶
func (c *Client) StartCycling(ctx context.Context, directory string, intervalSecs uint32, mode string) error
StartCycling starts cycling directory.
func (*Client) StopCycling ¶
StopCycling stops cycling.
type Cycling ¶
type Cycling struct {
Directory string
Images []string
Mode CyclingMode
Interval time.Duration
}
Cycling is the shared cycling pool and timing (CyclingConfig). Per-monitor positions live in MonitorState.
type CyclingMode ¶
type CyclingMode = config.CyclingMode
CyclingMode is the order images cycle in (types/cycling.rs).
func ParseCyclingMode ¶
func ParseCyclingMode(s string) (CyclingMode, error)
ParseCyclingMode reads a mode case-insensitively (CyclingMode::from_str).
type Daemon ¶
type Daemon struct {
// contains filtered or unexported fields
}
Daemon serves a Service as dev.stubbe.lys.Wallpaper1 (dbus/server.rs). An empty monitor argument targets every monitor.
func (*Daemon) ExtractColors ¶
ExtractColors extracts colors from the theming wallpaper.
func (*Daemon) GetFitMode ¶
GetFitMode is a monitor's fit mode; "fill" for an unknown monitor.
func (*Daemon) GetIsCycling ¶
GetIsCycling reports whether cycling is active.
func (*Daemon) ListMonitors ¶
ListMonitors lists the registered monitors.
func (*Daemon) RegisterMonitor ¶
RegisterMonitor registers a monitor.
func (*Daemon) SetFitMode ¶
SetFitMode sets the fit mode on a monitor, or all monitors for "".
func (*Daemon) SetThemingMonitor ¶
SetThemingMonitor picks the theming monitor; "" is the default.
func (*Daemon) SetWallpaper ¶
SetWallpaper sets path on a monitor, or all monitors for "".
func (*Daemon) StartCycling ¶
StartCycling starts cycling directory every intervalSecs.
func (*Daemon) UnregisterMonitor ¶
UnregisterMonitor unregisters a monitor.
type DirectoryNotFoundError ¶
type DirectoryNotFoundError struct{ Path string }
DirectoryNotFoundError is a cycling directory that does not exist.
func (*DirectoryNotFoundError) Error ¶
func (e *DirectoryNotFoundError) Error() string
type FitMode ¶
FitMode is how an image is scaled to its monitor (types/fit_mode.rs): the wallpaper schema enum.
func ParseFitMode ¶
ParseFitMode reads a mode case-insensitively, as FitMode::from_str does for the D-Bus interface.
type ImageNotFoundError ¶
type ImageNotFoundError struct{ Path string }
ImageNotFoundError is a wallpaper path that does not exist.
func (*ImageNotFoundError) Error ¶
func (e *ImageNotFoundError) Error() string
type MonitorState ¶
MonitorState is one monitor's wallpaper, scaling, and cycle position (types/monitor_state.rs). An empty Wallpaper means none is set.
type NoImagesFoundError ¶
type NoImagesFoundError struct{ Path string }
NoImagesFoundError is a cycling directory without a supported image.
func (*NoImagesFoundError) Error ¶
func (e *NoImagesFoundError) Error() string
type Options ¶
type Options struct {
// Extractor is the color extraction tool and its parameters.
Extractor extract.Config
// ThemingMonitor drives color extraction; empty falls back to the
// lowest-named monitor.
ThemingMonitor string
SharedCycle bool
// Sample reads a monitor's decoded wallpaper for the material
// extraction; the shell holds the rasters.
Sample Sampler
// Rand seeds shuffles and random starting indices; nil picks a
// random seed. Tests pass a fixed one.
Rand *rand.Rand
}
Options configure a Service (WallpaperServiceBuilder).
type Sampler ¶
Sampler reads the wallpaper a monitor shows, already decoded, as at most extract.SampleSide colors along its longer edge.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service is the wallpaper state manager (WallpaperService). All methods are safe for concurrent use; Run drives the cycling timer, the directory watcher, and color extraction.
func (*Service) Advance ¶
func (s *Service) Advance()
Advance moves every monitor to its next cycle image; a no-op without cycling.
func (*Service) Changes ¶
func (s *Service) Changes() (<-chan struct{}, func())
Changes ticks whenever the per-monitor state changes; read Monitors for the new value. The returned function unsubscribes.
func (*Service) CyclingConfig ¶
CyclingConfig snapshots the active cycling config; nil when stopped.
func (*Service) EndPreview ¶
func (s *Service) EndPreview()
EndPreview drops the previews: every monitor shows its set image again.
func (*Service) ExtractColors ¶
ExtractColors extracts the palette from the theming wallpaper unless it was already extracted (extract_colors). Every call ends with an Extracted tick, whether or not a tool ran.
func (*Service) Extracted ¶
func (s *Service) Extracted() (<-chan struct{}, func())
Extracted ticks after every color extraction pass, including passes that found nothing new to extract (watch_extraction): theme providers re-read the palette cache on it.
func (*Service) MonitorNames ¶
MonitorNames lists the registered monitors, sorted.
func (*Service) Monitors ¶
func (s *Service) Monitors() map[string]MonitorState
Monitors snapshots the per-monitor state as shown: a monitor previewing an image (SetPreview) shows that image.
func (*Service) RegisterMonitor ¶
RegisterMonitor adds a monitor. While cycling it starts at a distinct index (0 in sequential mode, the shared index or a random one in shuffle) showing that image; otherwise it starts with no wallpaper. Registering a known monitor is a no-op.
func (*Service) Rewind ¶
func (s *Service) Rewind()
Rewind moves every monitor to its previous cycle image; a no-op without cycling.
func (*Service) Run ¶
Run drives the service until ctx ends: the cycling timer and directory watcher (tasks/cycle_runner.rs) and the extraction loop (spawn_color_extractor), which extracts once at start.
func (*Service) SetCyclingInterval ¶
SetCyclingInterval changes the interval of an active cycle, which restarts the timer.
func (*Service) SetExtractor ¶
SetExtractor replaces the extraction tool config; a change re-extracts.
func (*Service) SetFitMode ¶
SetFitMode sets the mode on one monitor, or every monitor when monitor is empty; an unknown monitor is ignored.
func (*Service) SetPreview ¶
SetPreview shows path on one monitor, or every monitor when monitor is empty, without changing what is set: EndPreview puts the set images back. A missing file is an ImageNotFoundError.
func (*Service) SetSharedCycle ¶
SetSharedCycle toggles shared shuffle cycling. In an active shuffle cycle, turning it on moves every monitor to one index and off gives each a random one (handle_shared_cycle_change).
func (*Service) SetThemingMonitor ¶
SetThemingMonitor picks the monitor whose wallpaper drives color extraction; empty falls back to the lowest-named monitor. A change re-extracts.
func (*Service) SetWallpaper ¶
SetWallpaper sets path on one monitor, or every monitor when monitor is empty. An unknown monitor is ignored; a missing file is an ImageNotFoundError.
func (*Service) StartCycling ¶
StartCycling scans directory and starts cycling every monitor through it. Sequential starts every monitor at the first image; shuffle gives each its own random start, or one shared start with SharedCycle. The images are applied at once.
func (*Service) StopCycling ¶
func (s *Service) StopCycling()
StopCycling stops cycling; the monitors keep their current images.
func (*Service) ThemingMonitor ¶
ThemingMonitor is the configured theming monitor, empty for the fallback.
func (*Service) UnregisterMonitor ¶
UnregisterMonitor drops a monitor; unknown names are ignored.