package wallpaper

import (
	"bytes"
	"image"
	"image/png"
	"os"
	"os/exec"
)

var err error

func Wallpaper(img image.Image) error {
	/*
		cmd := exec.Command(
			"swaybg",
			"--image", "/dev/stdin",
			"--mode", "fill",
		)
	*/
	cmd := exec.Command("imv", "/dev/stdin")

	var buf = new(bytes.Buffer)
	err := png.Encode(buf, img)
	if err != nil {
		panic(err)
	}

	cmd.Stderr = os.Stdout
	cmd.Stdin = buf

	err = cmd.Run()
	if err != nil {
		return err
	}
	return nil
}
