lcpz / lain

Awesome WM complements
GNU General Public License v2.0
1.06k stars 210 forks source link

openweathermap api request use lat and lon instead of city id #545

Closed quantumfate closed 1 year ago

quantumfate commented 1 year ago

    function weather.forecast_update()
        local cmd = string.format(forecast_call, city_id, units, lang, APPID) -- needs refactoring
        helpers.async(cmd, function(f)
            local err
            weather_now, _, err = json.decode(f, 1, nil)

            if not err and type(weather_now) == "table" and tonumber(weather_now["cod"]) == 200 then
                weather.notification_text = ""
                for i = 1, weather_now["cnt"], weather_now["cnt"]//cnt do
                    weather.notification_text = weather.notification_text ..
                                                notification_text_fun(weather_now["list"][i])
                    if i < weather_now["cnt"] then
                        weather.notification_text = weather.notification_text .. "\n"
                    end
                end
            end
        end)
    end