wallpaper

package
v0.3.5 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2026 License: MIT Imports: 18 Imported by: 1 module, 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 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

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

View Source
const (
	FitFill    = config.FitFill
	FitFit     = config.FitFit
	FitCenter  = config.FitCenter
	FitStretch = config.FitStretch
)

Fit modes; Fill is the default.

View Source
const (
	Sequential = config.CyclingSequential
	Shuffle    = config.CyclingShuffle
)

Cycling modes; Sequential is the default.

Variables

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

func Export(conn *dbus.Conn, svc *Service) (func(), error)

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.

Types

type Client

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

Client drives a running daemon (the WallpaperProxy the CLI uses).

func Connect

func Connect() (*Client, error)

Connect dials the session bus.

func NewClient

func NewClient(conn *dbus.Conn) *Client

NewClient wraps an existing connection.

func (*Client) Close

func (c *Client) Close() error

Close drops the bus connection.

func (*Client) ExtractColors

func (c *Client) ExtractColors(ctx context.Context) error

ExtractColors re-runs color extraction.

func (*Client) GetFitMode

func (c *Client) GetFitMode(ctx context.Context, monitor string) (string, error)

GetFitMode reads a monitor's fit mode.

func (*Client) GetIsCycling

func (c *Client) GetIsCycling(ctx context.Context) (bool, error)

GetIsCycling reads whether cycling is active.

func (*Client) ListMonitors

func (c *Client) ListMonitors(ctx context.Context) ([]string, error)

ListMonitors lists the registered monitors.

func (*Client) Next

func (c *Client) Next(ctx context.Context) error

Next advances the cycle.

func (*Client) Previous

func (c *Client) Previous(ctx context.Context) error

Previous rewinds the cycle.

func (*Client) SetFitMode

func (c *Client) SetFitMode(ctx context.Context, mode, monitor string) error

SetFitMode sets the fit mode on monitor ("" for all).

func (*Client) SetThemingMonitor

func (c *Client) SetThemingMonitor(ctx context.Context, monitor string) error

SetThemingMonitor picks the theming monitor ("" for the default).

func (*Client) SetWallpaper

func (c *Client) SetWallpaper(ctx context.Context, path, monitor string) error

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

func (c *Client) StopCycling(ctx context.Context) error

StopCycling stops cycling.

func (*Client) WallpaperForMonitor

func (c *Client) WallpaperForMonitor(ctx context.Context, monitor string) (string, error)

WallpaperForMonitor reads a monitor's wallpaper path.

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.

func (*Cycling) ImageAt

func (c *Cycling) ImageAt(index int) (string, bool)

ImageAt is the image at index, wrapping; false for an empty pool.

func (*Cycling) ImageCount

func (c *Cycling) ImageCount() int

ImageCount is the pool size.

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

func (d *Daemon) ExtractColors() *dbus.Error

ExtractColors extracts colors from the theming wallpaper.

func (*Daemon) GetFitMode

func (d *Daemon) GetFitMode(monitor string) (string, *dbus.Error)

GetFitMode is a monitor's fit mode; "fill" for an unknown monitor.

func (*Daemon) GetIsCycling

func (d *Daemon) GetIsCycling() (bool, *dbus.Error)

GetIsCycling reports whether cycling is active.

func (*Daemon) ListMonitors

func (d *Daemon) ListMonitors() ([]string, *dbus.Error)

ListMonitors lists the registered monitors.

func (*Daemon) Next

func (d *Daemon) Next() *dbus.Error

Next advances every monitor to its next cycle image.

func (*Daemon) Previous

func (d *Daemon) Previous() *dbus.Error

Previous rewinds every monitor to its previous cycle image.

func (*Daemon) RegisterMonitor

func (d *Daemon) RegisterMonitor(monitor string) *dbus.Error

RegisterMonitor registers a monitor.

func (*Daemon) SetFitMode

func (d *Daemon) SetFitMode(mode, monitor string) *dbus.Error

SetFitMode sets the fit mode on a monitor, or all monitors for "".

func (*Daemon) SetThemingMonitor

func (d *Daemon) SetThemingMonitor(monitor string) *dbus.Error

SetThemingMonitor picks the theming monitor; "" is the default.

func (*Daemon) SetWallpaper

func (d *Daemon) SetWallpaper(path, monitor string) *dbus.Error

SetWallpaper sets path on a monitor, or all monitors for "".

func (*Daemon) StartCycling

func (d *Daemon) StartCycling(directory string, intervalSecs uint32, mode string) *dbus.Error

StartCycling starts cycling directory every intervalSecs.

func (*Daemon) StopCycling

func (d *Daemon) StopCycling() *dbus.Error

StopCycling stops cycling.

func (*Daemon) UnregisterMonitor

func (d *Daemon) UnregisterMonitor(monitor string) *dbus.Error

UnregisterMonitor unregisters a monitor.

func (*Daemon) WallpaperForMonitor

func (d *Daemon) WallpaperForMonitor(monitor string) (string, *dbus.Error)

WallpaperForMonitor is a monitor's wallpaper path, "" when unknown or unset.

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

type FitMode = config.FitMode

FitMode is how an image is scaled to its monitor (types/fit_mode.rs): the wallpaper schema enum.

func ParseFitMode

func ParseFitMode(s string) (FitMode, error)

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

type MonitorState struct {
	Wallpaper  string
	FitMode    FitMode
	CycleIndex int
}

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 shows the same image on every monitor in shuffle mode.
	SharedCycle bool
	// 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 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 New

func New(opts Options) *Service

New builds a service with no monitors and cycling stopped.

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

func (s *Service) CyclingConfig() *Cycling

CyclingConfig snapshots the active cycling config; nil when stopped.

func (*Service) ExtractColors

func (s *Service) ExtractColors(ctx context.Context) error

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

func (s *Service) FitModeOf(monitor string) (FitMode, bool)

FitModeOf is a monitor's fit mode; Fill and false when it is unknown.

func (*Service) MonitorNames

func (s *Service) MonitorNames() []string

MonitorNames lists the registered monitors, sorted.

func (*Service) Monitors

func (s *Service) Monitors() map[string]MonitorState

Monitors snapshots the per-monitor state.

func (*Service) RegisterMonitor

func (s *Service) RegisterMonitor(monitor string)

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

func (s *Service) Run(ctx context.Context)

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

func (s *Service) SetCyclingInterval(interval time.Duration)

SetCyclingInterval changes the interval of an active cycle, which restarts the timer.

func (*Service) SetExtractor

func (s *Service) SetExtractor(cfg extract.Config)

SetExtractor replaces the extraction tool config; a change re-extracts.

func (*Service) SetFitMode

func (s *Service) SetFitMode(mode FitMode, monitor string)

SetFitMode sets the mode on one monitor, or every monitor when monitor is empty; an unknown monitor is ignored.

func (*Service) SetSharedCycle

func (s *Service) SetSharedCycle(shared bool)

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

func (s *Service) SetThemingMonitor(monitor string)

SetThemingMonitor picks the monitor whose wallpaper drives color extraction; empty falls back to the lowest-named monitor. A change re-extracts.

func (*Service) SetWallpaper

func (s *Service) SetWallpaper(path, monitor string) error

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

func (s *Service) StartCycling(directory string, interval time.Duration, mode CyclingMode) error

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

func (s *Service) ThemingMonitor() string

ThemingMonitor is the configured theming monitor, empty for the fallback.

func (*Service) UnregisterMonitor

func (s *Service) UnregisterMonitor(monitor string)

UnregisterMonitor drops a monitor; unknown names are ignored.

func (*Service) Wallpaper

func (s *Service) Wallpaper(monitor string) (string, bool)

Wallpaper is a monitor's wallpaper; false when the monitor is unknown or has none.

Directories

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

Jump to

Keyboard shortcuts

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