summary refs log tree commit diff stats
path: root/main.go
diff options
context:
space:
mode:
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
 }