weather: remove dupes in forecast if no change

This commit is contained in:
Vincent Bernat 2021-08-10 13:14:22 +02:00
parent 0559c830ef
commit 85b56cd2d5
2 changed files with 9 additions and 3 deletions

View file

@ -152,11 +152,17 @@ if __name__ == "__main__":
logger.info(f"current weather: {description}")
# Format output
output = "{} {} {}".format(
forecasts = [
format_weather(forecast_weather["list"][0]),
format_weather(forecast_weather["list"][1]),
format_weather(forecast_weather["list"][2]),
)
]
while len(forecasts) >= 2:
if forecasts[-1] == forecasts[-2]:
forecasts.pop()
else:
break
output = " ".join(forecasts)
output = output.replace("%{Tx}", "%%{T%d}" % options.font)
logger.debug("output: %s", output)

View file

@ -1,5 +1,5 @@
[Unit]
Description=Build and display wallpaper
Description=Update weather for Polybar
PartOf=graphical-session.target
After=polybar.service