diff options
-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 } |