summary refs log tree commit diff stats
path: root/pkg/background/set.go
blob: 2badc48a11bccededf227343b0b33d3b21f9b703 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
package background

import (
	"fmt"
	"os"
	"os/exec"
)

// Set calls feh to set the background
func Set(path string) error {
	switch os.Getenv("XDG_CURRENT_DESKTOP") {
	case "GNOME", "Unity", "Pantheon":
		path = fmt.Sprintf("%s%s", "file://", path)
		err = exec.Command("gsettings", "set org.gnome.desktop.background picture-uri", path).Run()
		return err
	case "LXDE":
		err = exec.Command("pcmanfm", "-w", path).Run()
		return err
	default:
		feh, err := exec.LookPath("feh")
		if err != nil {
			return err
		}
		err = exec.Command(feh, "--bg-fill", path).Run()
		return err
	}
}