mirror of https://github.com/lcpz/lain.git
satisfied 'issue' #14
This commit is contained in:
parent
a4e789e05b
commit
4a29739e79
|
@ -46,8 +46,7 @@ yawn_notification_preset = {}
|
||||||
|
|
||||||
local function fetch_weather()
|
local function fetch_weather()
|
||||||
local url = api_url .. units_set .. city_id
|
local url = api_url .. units_set .. city_id
|
||||||
local f = io.popen("curl --connect-timeout 1 -fsm 1 '"
|
local f = io.popen("curl --connect-timeout 1 -fsm 1 '" .. url .. "'" )
|
||||||
.. url .. "'" )
|
|
||||||
local text = f:read("*all")
|
local text = f:read("*all")
|
||||||
f:close()
|
f:close()
|
||||||
|
|
||||||
|
@ -58,12 +57,12 @@ local function fetch_weather()
|
||||||
yawn.icon:set_image(icon_path .. "na.png")
|
yawn.icon:set_image(icon_path .. "na.png")
|
||||||
if text == "" then
|
if text == "" then
|
||||||
weather_data = "Service not available at the moment."
|
weather_data = "Service not available at the moment."
|
||||||
yawn.widget:set_text("N/A")
|
yawn.widget:set_text(" N/A")
|
||||||
else
|
else
|
||||||
weather_data = "City not found!\n" ..
|
weather_data = "City not found!\n" ..
|
||||||
"Are you sure " .. city_id ..
|
"Are you sure " .. city_id ..
|
||||||
" is your Yahoo city ID?"
|
" is your Yahoo city ID?"
|
||||||
yawn.widget:set_text("?")
|
yawn.widget:set_text(" ?")
|
||||||
end
|
end
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
@ -75,7 +74,7 @@ local function fetch_weather()
|
||||||
-- may still happens in case of bad connectivity
|
-- may still happens in case of bad connectivity
|
||||||
if weather_data == "" then
|
if weather_data == "" then
|
||||||
yawn.icon:set_image(icon_path .. "na.png")
|
yawn.icon:set_image(icon_path .. "na.png")
|
||||||
yawn.widget:set_text("?")
|
yawn.widget:set_text(" ?")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -149,7 +148,7 @@ function yawn.hide()
|
||||||
end
|
end
|
||||||
|
|
||||||
function yawn.show(t_out)
|
function yawn.show(t_out)
|
||||||
if yawn.widget._layout.text == "?"
|
if yawn.widget._layout.text:match("?")
|
||||||
then
|
then
|
||||||
fetch_weather(settings)
|
fetch_weather(settings)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue