diff options
author | Andinus <andinus@inventati.org> | 2020-03-12 00:35:29 +0530 |
---|---|---|
committer | Andinus <andinus@inventati.org> | 2020-03-12 00:35:29 +0530 |
commit | e62b5c1dfd9cc85d1e0766e6cd085fbf0b58405b (patch) | |
tree | 965395fc84f262b1dd7a40690398c6e2fc6d955c | |
parent | f7edf1c239cf374e1a22daca016dac47c35da88c (diff) | |
download | cetus-e62b5c1dfd9cc85d1e0766e6cd085fbf0b58405b.tar.gz |
Add image setting capability
-rw-r--r-- | README.org | 11 | ||||
-rw-r--r-- | main.go | 35 |
2 files changed, 45 insertions, 1 deletions
diff --git a/README.org b/README.org index f24d0ab..53074d3 100644 --- a/README.org +++ b/README.org @@ -3,5 +3,14 @@ Cetus is a wallpaper setting tool written in Go. This is a work in-progress. * Features -** TODO Set given wallpaper +** Supports various Image of the Day services +There are several Image of the Day services on the web, cetus will pull the +latest image & set it as wallpaper. +*** TODO NASA Image of the Day +*** TODO Bing Image of the Day +** DONE Set given wallpaper Takes a path as input & sets it as wallpaper. + +* Dependency +** [[https://feh.finalrewind.org/][feh]] +Required to set the wallpaper. 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 } |