diff --git a/config.yml b/config.yml index 1af0e5d9..8f12f93b 100644 --- a/config.yml +++ b/config.yml @@ -22,7 +22,7 @@ wtf: secretFile: "~/.wtf/gcal/client_secret.json" git: commitCount: 5 - enabled: true + enabled: false position: top: 0 left: 2 @@ -51,7 +51,7 @@ wtf: refreshInterval: 900 newrelic: applicationId: 10549735 - enabled: true + enabled: false deployCount: 7 position: top: 4 @@ -68,7 +68,7 @@ wtf: width: 1 refreshInterval: 21600 security: - enabled: true + enabled: false position: top: 5 left: 0 @@ -76,7 +76,7 @@ wtf: width: 1 refreshInterval: 3600 status: - enabled: true + enabled: false position: top: 5 left: 2 @@ -85,7 +85,7 @@ wtf: refreshInterval: 1 weather: cityId: 6173331 - enabled: false + enabled: true language: "EN" position: top: 0 diff --git a/weather/client.go b/weather/client.go index ecd2e980..935e5db5 100644 --- a/weather/client.go +++ b/weather/client.go @@ -11,18 +11,20 @@ import ( func Fetch(cityID int) *owm.CurrentWeatherData { apiKey := os.Getenv("WTF_OWM_API_KEY") - return currentWeather(apiKey, cityID) + data, _ := currentWeather(apiKey, cityID) + + return data } /* -------------------- Unexported Functions -------------------- */ -func currentWeather(apiKey string, cityCode int) *owm.CurrentWeatherData { +func currentWeather(apiKey string, cityCode int) (*owm.CurrentWeatherData, error) { weather, err := owm.NewCurrent(Config.UString("wtf.weather.tempUnit", "C"), Config.UString("wtf.weather.language", "EN"), apiKey) if err != nil { - panic(err) + return nil, err } weather.CurrentByID(cityCode) - return weather + return weather, nil } diff --git a/weather/widget.go b/weather/widget.go index c3b3cad4..5564a3d8 100644 --- a/weather/widget.go +++ b/weather/widget.go @@ -59,6 +59,10 @@ func (widget *Widget) addView() { } func (widget *Widget) contentFrom(data *owm.CurrentWeatherData) string { + if len(data.Weather) == 0 { + return " Weather data is unavailable." + } + str := "\n" descs := []string{} @@ -90,6 +94,10 @@ func (widget *Widget) contentFrom(data *owm.CurrentWeatherData) string { func icon(data *owm.CurrentWeatherData) string { var icon string + if len(data.Weather) == 0 { + return "" + } + switch data.Weather[0].Description { case "broken clouds": icon = "☁️"