summary refs log tree commit diff stats
path: root/main.go
diff options
context:
space:
mode:
authorAndinus <andinus@inventati.org>2020-03-12 00:35:29 +0530
committerAndinus <andinus@inventati.org>2020-03-12 00:35:29 +0530
commite62b5c1dfd9cc85d1e0766e6cd085fbf0b58405b (patch)
tree965395fc84f262b1dd7a40690398c6e2fc6d955c /main.go
parentf7edf1c239cf374e1a22daca016dac47c35da88c (diff)
downloadcetus-e62b5c1dfd9cc85d1e0766e6cd085fbf0b58405b.tar.gz
Add image setting capability
Diffstat (limited to 'main.go')
-rw-r--r--main.go35
1 files changed, 35 insertions, 0 deletions
diff --git a/main.go b/main.go
index a208c0e..aa1e639 100644
--- a/main.go
+++ b/main.go
@@ -14,6 +14,41 @@
 
 package main
 
+import (
+	"flag"
+	"fmt"
+	"log"
+	"os/exec"
+)
+
 func main() {
+	var (
+		imgPath string
+		err     error
+	)
+
+	// Parse flags passed to program
+	flag.StringVar(&imgPath, "img-path", "", "Image to set as wallpaper")
+	flag.Parse()
+
+	if len(imgPath) > 0 {
+		err = setWall(imgPath)
+		if err != nil {
+			log.Fatal(err)
+		}
+		return
+	}
+}
+
+func setWall(imgPath string) error {
+	var err error
+
+	feh, err := exec.LookPath("feh")
+	if err != nil {
+		fmt.Println("Error: feh is not in $PATH")
+		return err
+	}
 
+	err = exec.Command(feh, "--bg-fill", imgPath).Run()
+	return err
 }