summary refs log tree commit diff stats
path: root/pkg/background
diff options
context:
space:
mode:
authorAndinus <andinus@nand.sh>2020-03-19 16:56:43 +0530
committerAndinus <andinus@nand.sh>2020-03-19 16:56:43 +0530
commit8cf76e6a9c04509d460e0bfd485e17abf030b6b4 (patch)
treed772fb82e4a496b1956615d178e3db161050264b /pkg/background
parent51cbcc47488116cb5bdf45c05c5c39eddb4d4771 (diff)
downloadcetus-8cf76e6a9c04509d460e0bfd485e17abf030b6b4.tar.gz
Add support for other desktop environments
Diffstat (limited to 'pkg/background')
-rw-r--r--pkg/background/set.go24
1 files changed, 19 insertions, 5 deletions
diff --git a/pkg/background/set.go b/pkg/background/set.go
index fa95f6f..2badc48 100644
--- a/pkg/background/set.go
+++ b/pkg/background/set.go
@@ -1,13 +1,27 @@
 package background
 
-import "os/exec"
+import (
+	"fmt"
+	"os"
+	"os/exec"
+)
 
 // Set calls feh to set the background
 func Set(path string) error {
-	feh, err := exec.LookPath("feh")
-	if err != nil {
+	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
 	}
-	err = exec.Command(feh, "--bg-fill", path).Run()
-	return err
 }