X-Git-Url: https://git.madduck.net/etc/awesome.git/blobdiff_plain/2151e99477925744d22c8ac1da9bb371217ed5f2..d83966b518792efede931b337313991180056f9a:/widgets/yawn/init.lua diff --git a/widgets/yawn/init.lua b/widgets/yawn/init.lua index e7aa75d..36cdf54 100644 --- a/widgets/yawn/init.lua +++ b/widgets/yawn/init.lua @@ -46,8 +46,7 @@ yawn_notification_preset = {} local function fetch_weather() local url = api_url .. units_set .. city_id - local f = io.popen("curl --connect-timeout 1 -fsm 1 '" - .. url .. "'" ) + local f = io.popen("curl --connect-timeout 1 -fsm 3 '" .. url .. "'" ) local text = f:read("*all") f:close() @@ -58,12 +57,12 @@ local function fetch_weather() yawn.icon:set_image(icon_path .. "na.png") if text == "" then weather_data = "Service not available at the moment." - yawn.widget:set_text("N/A") + yawn.widget:set_text(" N/A") else weather_data = "City not found!\n" .. "Are you sure " .. city_id .. " is your Yahoo city ID?" - yawn.widget:set_text("?") + yawn.widget:set_text(" ?") end return end @@ -75,7 +74,7 @@ local function fetch_weather() -- may still happens in case of bad connectivity if weather_data == "" then yawn.icon:set_image(icon_path .. "na.png") - yawn.widget:set_text("?") + yawn.widget:set_text(" ?") return end @@ -114,11 +113,8 @@ local function fetch_weather() sky = sky .. forecast:gsub(" ", ""):gsub("/", "") .. ".png" -- In case there's no defined icon for current forecast - f = io.open(sky) - if f == nil then + if io.open(sky) == nil then sky = icon_path .. "na.png" - else - io.close(f) end -- Localization @@ -152,7 +148,7 @@ function yawn.hide() end function yawn.show(t_out) - if yawn.widget._layout.text == "?" + if yawn.widget._layout.text:match("?") then fetch_weather(settings) end