summaryrefslogtreecommitdiff
path: root/weather-widget
diff options
context:
space:
mode:
Diffstat (limited to 'weather-widget')
-rw-r--r--weather-widget/weather.lua11
1 files changed, 9 insertions, 2 deletions
diff --git a/weather-widget/weather.lua b/weather-widget/weather.lua
index 973a776..06897b7 100644
--- a/weather-widget/weather.lua
+++ b/weather-widget/weather.lua
@@ -98,8 +98,15 @@ local weather_timer = gears.timer({ timeout = 60 })
local resp
weather_timer:connect_signal("timeout", function ()
- local resp_json = http.request("https://api.openweathermap.org/data/2.5/weather?q=" .. secrets.weather_widget_city .."&appid=" .. secrets.weather_widget_api_key)
- if (resp_json ~= nil) then
+ local resp_json, status = http.request("https://api.openweathermap.org/data/2.5/weather?q=" .. secrets.weather_widget_city .."&appid=" .. secrets.weather_widget_api_key)
+ if (status ~= 200) then
+ local err_resp = json.decode(resp_json)
+ naughty.notify{
+ title = 'Weather Widget Error',
+ text = err_resp.message,
+ preset = naughty.config.presets.critical,
+ }
+ elseif (resp_json ~= nil) then
resp = json.decode(resp_json)
icon_widget.image = path_to_icons .. icon_map[resp.weather[1].icon]
temp_widget:set_text(to_celcius(resp.main.temp) .. "°C")