loop

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const EnvBackend = "LAZYWAL_BACKEND"

EnvBackend names a backend to use instead of auto-selecting one.

Variables

View Source
var BackendsCmd = &bonzai.Cmd{
	Name:    `backends`,
	Alias:   `backend`,
	Usage:   `lazywal backends`,
	Short:   `list backends and the one this session uses`,
	NumArgs: 0,
	Cmds:    []*bonzai.Cmd{HelpCmd},

	Mcp: &bonzai.McpMeta{
		Desc: "List wallpaper backends, whether each is ready, and which one the current session uses",
	},

	Do: func(_ *bonzai.Cmd, _ ...string) error {
		app, err := newApp()
		if err != nil {
			return err
		}
		svc := app.Service
		fmt.Println(svc.Session)

		selected, _ := svc.Backend()
		for _, b := range svc.Registry.All() {
			mark := " "
			if selected != nil && b.Name() == selected.Name() {
				mark = "*"
			}
			status := "ready"
			if err := b.Check(); err != nil {
				status = err.Error()
			}
			fmt.Printf("%s %-11s %s\n  %11s  %s\n", mark, b.Name(), b.Describe(), "", status)
		}
		fmt.Printf("\n* = selected; override with %s=<name>\n", EnvBackend)
		fmt.Printf("Add your own backends in %s\n", custom.DefaultPath())
		return nil
	},
}
View Source
var ClearCmd = &bonzai.Cmd{
	Name:    `clear`,
	Alias:   `kill`,
	Usage:   `lazywal clear`,
	Short:   `stop the video wallpaper and restore the desktop`,
	MinArgs: 0,
	Cmds:    []*bonzai.Cmd{HelpCmd},

	Mcp: &bonzai.McpMeta{
		Desc: "Clear the video wallpaper using the backend that set it",
	},

	Do: func(_ *bonzai.Cmd, _ ...string) error {
		app, err := newApp()
		if err != nil {
			return err
		}
		b, err := app.Service.Clear()
		switch {
		case err != nil:
			return err
		case b == nil:
			fmt.Println("Nothing to clear")
		default:
			fmt.Printf("Cleared video wallpaper (backend: %s)\n", b.Name())
		}
		return nil
	},
}
View Source
var Cmd = &bonzai.Cmd{
	Name:  `lazywal`,
	Short: `video/gif wallpaper client`,
	Vers:  version(),

	Cmds: []*bonzai.Cmd{
		HelpCmd,
		LoopCmd, ClearCmd, PywalCmd, BackendsCmd, DepsCmd,
	},

	Do: func(x *bonzai.Cmd, args ...string) error {
		return showHelp(x)
	},

	Long: `
Lazywal: a terminal client to help setup video-loops/gifs as background.

Copyright 2021-2024 Zayac-The-Engineer, 2024-2025 Pedro G. Branquinho (Go version)
License: MIT License
Site: buddhilw.com
Source: git@github.com/BuddhiLW/lazywal.git
Issues: github.com/BuddhiLW/lazywal/issues

You can use the following commands:

* lazywal set <path>                    (Auto-detects desktop and monitors)
* lazywal set <path> colors             (Also apply pywal colors)
* lazywal clear                         (Stops the wallpaper, restores the desktop)
* lazywal pywal                         (Updates color scheme using pywal)
* lazywal backends                      (Shows detected session and backends)

Backends (auto-selected; override with LAZYWAL_BACKEND=<name>):
* xwinwrap     - X11 window managers (xmonad, i3, bspwm...)
* mate, cinnamon, xfce, lxqt, lxde - X11 desktops (hide desktop icons while playing)
* x11-desktop  - other X11 desktops with panels
* gnome        - GNOME Wayland/X11, via the Hanabi extension
* plasma       - KDE Plasma 6, via Smart Video Wallpaper Reborn
* mpvpaper     - Hyprland, Sway, river, niri, Wayfire, labwc, KDE, COSMIC...
* your own     - defined in ~/.config/lazywal/backends.json

Features:
* Multi-monitor support with correct positioning
* Pywal integration for system-wide color schemes
* Handles video files and animated GIFs

See the README.md for more information and examples.
`,
}
View Source
var DepsCmd = &bonzai.Cmd{
	Name:    `test`,
	Alias:   `dependencies`,
	Usage:   `lazywal test`,
	Short:   `test to see if all dependencies are available`,
	NumArgs: 0,

	Do: func(_ *bonzai.Cmd, _ ...string) error {
		app, err := newApp()
		if err != nil {
			return err
		}
		b, selErr := app.Service.Backend()
		if b == nil {
			return selErr
		}
		if optional := app.Colors.Check(); optional != nil {
			fmt.Printf("Optional, for colors: %s\n", optional)
		}
		if err := b.Check(); err != nil {
			fmt.Println("Lazywal won't run.")
			return fmt.Errorf("%sbackend %s: %s%s%s", yellow, b.Name(), red, err, reset)
		}
		fmt.Printf("All dependencies installed (backend: %s)\n", b.Name())
		return nil
	},
}

DepsCmd checks the dependencies of the backend this session would use.

View Source
var HelpCmd = &bonzai.Cmd{
	Name:  `help`,
	Alias: `h|?`,
	Short: `display help information`,
	Do: func(x *bonzai.Cmd, args ...string) error {
		caller := x.Caller()
		if caller != nil && caller != x {
			return showHelp(caller)
		}

		return showHelp(x)
	},
}

HelpCmd provides basic help functionality

View Source
var LoopCmd = &bonzai.Cmd{
	Name:    `set`,
	Alias:   `set-path|path`,
	Usage:   `lazywal set <path> [colors]`,
	Short:   `set video wallpaper from given path`,
	MinArgs: 1,
	Cmds:    []*bonzai.Cmd{HelpCmd},

	Mcp: &bonzai.McpMeta{
		Desc: "Set a video or animated GIF as wallpaper on all monitors",
		Params: []bonzai.McpParam{
			{Name: "path", Desc: "Absolute path to video or GIF file", Type: "string", Required: true},
		},
	},

	Do: func(x *bonzai.Cmd, args ...string) error {
		a, err := parseSetArgs(args)
		if err != nil {
			return fmt.Errorf("%w (usage: %s)", err, x.Usage)
		}
		if a.display != "" {
			log.Printf("Ignoring display %s: monitors are detected automatically", a.display)
		}
		video, err := wallpaper.NewVideo(a.path)
		if err != nil {
			return err
		}
		log.Print("File chosen: ", video)

		app, err := newApp()
		if err != nil {
			return err
		}
		if _, err := app.Service.Set(video); err != nil {
			return err
		}
		if a.colors {
			return app.Colors.Apply(video)
		}
		return nil
	},
}
View Source
var PywalCmd = &bonzai.Cmd{
	Name:    `pywal`,
	Alias:   `update-pywal|colors`,
	Usage:   `lazywal pywal`,
	Short:   `apply pywal colors from random video frame`,
	NumArgs: 0,
	Cmds:    []*bonzai.Cmd{HelpCmd},

	Mcp: &bonzai.McpMeta{
		Desc: "Extract a random frame from the current wallpaper and apply pywal color scheme",
	},

	Do: func(_ *bonzai.Cmd, _ ...string) error {
		app, err := newApp()
		if err != nil {
			return err
		}
		video, err := app.Service.Current()
		if err != nil {
			return err
		}
		return app.Colors.Apply(video)
	},
}
View Source
var Version = ""

Version is stamped at build time by the Makefile and release workflow:

go build -ldflags "-X github.com/BuddhiLW/lazywal/loop.Version=v1.5.0"

When empty, the module version recorded by `go install ...@vX.Y.Z` (or the VCS-derived version of a local build) is used, so it can't drift from the release tag the way a hard-coded string did.

Functions

func Matches

func Matches(cmd *bonzai.Cmd, arg string) bool

Matches checks if arg matches the command's name or any of its aliases

Types

This section is empty.

Jump to

Keyboard shortcuts

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