Browse Source

Check for existance of path instead of GOOS

master
Gregory Rudolph 3 years ago
parent
commit
db50451be6
Signed by: rudi
GPG Key ID: EF64F3CBD1A1EBDD
  1. 9
      main.go

9
main.go

@ -6,7 +6,6 @@ import (
"log" "log"
"net/http" "net/http"
"os" "os"
"runtime"
"github.com/reujab/wallpaper" "github.com/reujab/wallpaper"
) )
@ -29,7 +28,7 @@ func main() {
} }
err = wallpaper.SetFromURL(apod.Hdurl) err = wallpaper.SetFromURL(apod.Hdurl)
if err != nil { if err != nil {
log.Fatalf("\nUnable to set wallpaper\n") log.Fatalf("\nUnable to set wallpaper: %+v\n", err)
return return
} }
err = wallpaper.SetMode(wallpaper.Center) err = wallpaper.SetMode(wallpaper.Center)
@ -37,11 +36,11 @@ func main() {
log.Fatalf("\nUnable to set wallpaper mode\n") log.Fatalf("\nUnable to set wallpaper mode\n")
return return
} }
// https://gist.github.com/mattes/d13e273314c3b3ade33f
if runtime.GOOS != "windows" { if _, err := os.Stat("/usr/share/backgrounds/spaceface"); !os.IsNotExist(err) {
err = downloadFile("/usr/share/backgrounds/spaceface/lock.jpg", apod.Hdurl) err = downloadFile("/usr/share/backgrounds/spaceface/lock.jpg", apod.Hdurl)
if err != nil { if err != nil {
log.Fatalf("\nUnable to Download lock.jpg image\n") log.Fatalf("\nUnable to Download lock.jpg image: %+v\n", err)
return return
} }
} }

Loading…
Cancel
Save