summary refs log tree commit diff stats
path: root/pkg/background/set_unix.go
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/background/set_unix.go')
-rw-r--r--pkg/background/set_unix.go30
1 files changed, 30 insertions, 0 deletions
diff --git a/pkg/background/set_unix.go b/pkg/background/set_unix.go
new file mode 100644
index 0000000..cd75ae3
--- /dev/null
+++ b/pkg/background/set_unix.go
@@ -0,0 +1,30 @@
+// +build linux netbsd openbsd freebsd dragonfly
+
+package background
+
+import (
+	"fmt"
+	"os"
+	"os/exec"
+)
+
+// Set calls feh to set the background
+func Set(path string) error {
+	var err 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
+	}
+}