mirror of
https://github.com/streetturtle/awesome-wm-widgets.git
synced 2024-11-17 07:49:09 +01:00
fix weather widget crash with no internet connection
This commit is contained in:
parent
9fbcb2e540
commit
b6458cbe0c
1 changed files with 5 additions and 3 deletions
|
@ -62,9 +62,11 @@ local resp
|
|||
|
||||
weather_timer:connect_signal("timeout", function ()
|
||||
local resp_json = http.request("http://api.openweathermap.org/data/2.5/weather?q=" .. city .."&appid=" .. open_map_key)
|
||||
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))
|
||||
if (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))
|
||||
end
|
||||
end)
|
||||
weather_timer:emit_signal("timeout")
|
||||
|
||||
|
|
Loading…
Reference in a new issue