loop

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	VarPrefix      = "lazywal_"
	VarPath        = VarPrefix + "path"
	VarPIDs        = VarPrefix + "pids"
	VarMonitorPIDs = VarPrefix + "monitor_pids"
)

Variables

View Source
var ClearCmd = &bonzai.Cmd{
	Name:    `clear`,
	Alias:   `kill`,
	Usage:   `lazywal clear`,
	Short:   `kill all xwinwrap processes that may be hanging`,
	MinArgs: 0,
	Cmds:    []*bonzai.Cmd{HelpCmd},

	Mcp: &bonzai.McpMeta{
		Desc: "Clear the wallpaper by killing all xwinwrap processes",
	},

	Do: func(x *bonzai.Cmd, _ ...string) error {
		fmt.Println("Killing all xwinwrap processes")
		cmd := exec.Command("pkill", "xwinwrap")
		return cmd.Run()
	},
}
View Source
var Cmd = &bonzai.Cmd{
	Name:  `lazywal`,
	Short: `video/gif wallpaper client`,
	Vers:  `v1.3.0`,

	Cmds: []*bonzai.Cmd{
		HelpCmd,
		LoopCmd, ClearCmd, PywalCmd, dependencies.TestDepsCmd,
	},

	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 monitor configuration)
* lazywal set <path> display <WxH>      (Manual display size - e.g. 1440x1080)
* lazywal kill                          (Kills all xwinwrap processes)
* lazywal pywal                         (Updates color scheme using pywal)

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

Dependencies:
* xwinwrap - For window creation
* mpv     - For video playback
* xrandr  - For monitor detection
* pywal   - Optional, for color scheme generation

See the README.md for more information and examples.
`,
}
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> [display <dimension>]`,
	Short:   `set video wallpaper from given path`,
	MinArgs: 1,
	Cmds:    []*bonzai.Cmd{HelpCmd, SetDisplayCmd},

	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 {
		path := args[0]
		if !validPath(path) {
			return fmt.Errorf("invalid path: %s", path)
		}

		log.Print("File chosen: ", path)
		Wall.Config.Path = path

		err := dependencies.TestDepsCmd.Do(x, args[0])
		if err != nil {
			return err
		}

		if len(args) < 2 {
			err := SetDisplayCmd.Do(x, defaultDisplay)
			if err != nil {
				return err
			}
			return nil
		}

		if len(args) > 2 && args[1] == "display" {
			err := SetDisplayCmd.Do(x, args[2:]...)
			if err != nil {
				return err
			}
		}

		if len(args) > 0 && Matches(PywalCmd, args[len(args)-1]) {
			err := PywalCmd.Do(x)
			if err != nil {
				return err
			}
		}

		return nil
	},
}
View Source
var PywalCmd = &bonzai.Cmd{
	Name:    `pywal`,
	Alias:   `update-pywal|colors`,
	Usage:   `lazywal set <path> colors`,
	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, args ...string) error {
		available, err := dependencies.IsWalAvailable()
		if available {
			fmt.Println("wal is available in your system.")
		} else {
			return err
		}
		Wall.Pywal()
		return nil
	},
}
View Source
var SetDisplayCmd = &bonzai.Cmd{
	Name:    `display`,
	Alias:   `setdisplay|set`,
	Usage:   `<path>`,
	Short:   `set wallpaper to screen dimensions`,
	NumArgs: 1,
	Cmds:    []*bonzai.Cmd{HelpCmd},

	Do: func(_ *bonzai.Cmd, args ...string) error {
		err := SetDisplay(args[0])
		if err != nil {
			return err
		}
		return Wall.Set()
	},
}

Functions

func GetDefaultDisplay

func GetDefaultDisplay() string

func Matches

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

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

func SetDisplay

func SetDisplay(display string) error

func UpdatePywalScheme

func UpdatePywalScheme(image string) error

Types

type Config

type Config struct {
	Path       string
	Dimensions *Size
	LastUsed   string // still not used
}

func NewConfig

func NewConfig() *Config

type Monitor added in v1.1.0

type Monitor struct {
	Name       string
	Dimensions Size
	Position   Position
	Primary    bool
}

func GetMonitors added in v1.1.0

func GetMonitors() ([]Monitor, error)

type Position added in v1.1.0

type Position struct {
	X float32
	Y float32
}

type Size

type Size struct {
	Width  float32
	Height float32
}

type Wallpaper

type Wallpaper struct {
	Config   *Config
	Running  map[string]*exec.Cmd
	Monitors []Monitor
}
var (
	Wall *Wallpaper = NewWallPaper(NewConfig())
)

func NewWallPaper

func NewWallPaper(setup *Config) *Wallpaper

func (*Wallpaper) Pywal

func (w *Wallpaper) Pywal()

func (*Wallpaper) Set

func (w *Wallpaper) Set() error

Jump to

Keyboard shortcuts

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