diff --git a/bin/polybar-weather b/bin/polybar-weather index 126384b..5cd2a64 100755 --- a/bin/polybar-weather +++ b/bin/polybar-weather @@ -160,9 +160,14 @@ if __name__ == "__main__": current_weather = get_weather(options.owm_api_key, *location, "weather") if options.forecasts: forecast_weather = get_weather( - options.owm_api_key, *location, "forecast", count=options.forecasts + options.owm_api_key, *location, "forecast", count=options.forecasts+1 )["list"] - logger.info(f"first forecast: {forecast_weather[0]['dt_txt']} UTC") + if forecast_weather[0]['dt'] - time.time() < 7200: + logger.debug("discard first forecast, too soon") + forecast_weather = forecast_weather[1:] + else: + forecast_weather.pop() + logger.info(f"next forecast: {forecast_weather[0]['dt_txt']} UTC") else: forecast_weather = [] description = current_weather["weather"][0]["description"]