polybar-weather: use different icons when day/night

Also, on hot days, switch to a specific icon.
This commit is contained in:
Vincent Bernat 2021-08-10 13:33:21 +02:00
parent 7a63def56f
commit 78004178e4

View file

@ -47,26 +47,29 @@ def format_weather(data):
"""Translate OWM icon to WeatherIcons.""" """Translate OWM icon to WeatherIcons."""
icon = data["weather"][0]["icon"] icon = data["weather"][0]["icon"]
temperature = data["main"]["temp"] temperature = data["main"]["temp"]
icon = { if icon == "01d" and temperature > 32:
"01d": "\uf00d", # Clear sky - day icon = "\uf072"
"01n": "\uf02e", # Clear sky - night else:
"02d": "\uf002", # Few clouds (11-25%) - day icon = {
"02n": "\uf086", # Few clouds (11-25%) - night "01d": "\uf00d", # Clear sky - day
"03d": "\uf041", # Scattered clouds (25-50%) - day/night "01n": "\uf02e", # Clear sky - night
"03n": "\uf041", # Scattered clouds (25-50%) - day/night "02d": "\uf002", # Few clouds (11-25%) - day
"04d": "\uf013", # Broken / Overcast clouds (51-84% / 85-100%) - day/night "02n": "\uf083", # Few clouds (11-25%) - night
"04n": "\uf013", # Broken / Overcast clouds (51-84% / 85-100%) - day/night "03d": "\uf041", # Scattered clouds (25-50%) - day/night
"09d": "\uf018", # Shower rain - day "03n": "\uf086", # Scattered clouds (25-50%) - day/night
"09n": "\uf018", # Shower rain - night "04d": "\uf013", # Broken / Overcast clouds (51-84% / 85-100%) - day/night
"10d": "\uf008", # Moderate / heavy rain - day "04n": "\uf013", # Broken / Overcast clouds (51-84% / 85-100%) - day/night
"10n": "\uf036", # Moderate / heavy rain - night "09d": "\uf009", # Shower rain - day
"11d": "\uf005", # Thunderstorm - day "09n": "\uf037", # Shower rain - night
"11n": "\uf025", # Thunderstorm - night "10d": "\uf008", # Moderate / heavy rain - day
"13d": "\uf00a", # Snow - day "10n": "\uf036", # Moderate / heavy rain - night
"13n": "\uf02a", # Snow - night "11d": "\uf005", # Thunderstorm - day
"50d": "\uf003", # Fog - day "11n": "\uf025", # Thunderstorm - night
"50n": "\uf04a", # Fog - night "13d": "\uf00a", # Snow - day
}.get(icon, "\uf075") "13n": "\uf02a", # Snow - night
"50d": "\uf003", # Fog - day
"50n": "\uf04a", # Fog - night
}.get(icon, "\uf075")
return "".join( return "".join(
[ [
"%{Tx}", "%{Tx}",