Simple weather output for i3blocks status bar
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
495 B

package main
import (
"fmt"
"log"
"os"
"strconv"
owm "github.com/briandowns/openweathermap"
)
var apiKey string
func init() {
apiKey = os.Getenv("OWM_API_KEY")
if apiKey == "" {
log.Fatal("No API key")
}
}
func main() {
w, err := owm.NewCurrent("F", "en", apiKey)
if err != nil {
log.Fatalln(err)
}
err = w.CurrentByZip(97351, "us")
if err != nil {
log.Fatalln(err)
}
out := w.Weather[0].Description + " " + strconv.Itoa(int(w.Main.Temp)) + " °F"
fmt.Println(out)
}