weather
This commit is contained in:
@@ -12,7 +12,6 @@ let
|
||||
#! nix-shell -i python3 --pure
|
||||
#! nix-shell -p python3 python3Packages.requests
|
||||
|
||||
"""get waybar weather"""
|
||||
import os
|
||||
import json
|
||||
import shutil
|
||||
@@ -98,12 +97,16 @@ let
|
||||
WIND_DIRECTION = {
|
||||
"S": "↓",
|
||||
"SW": "↙",
|
||||
"SSW": "↙",
|
||||
"W": "←",
|
||||
"NW": "↖",
|
||||
"NNW": "↖",
|
||||
"N": "↑",
|
||||
"NE": "↗",
|
||||
"NNE": "↗",
|
||||
"E": "→",
|
||||
"SE": "↘",
|
||||
"SSE": "↘",
|
||||
}
|
||||
|
||||
MOON_PHASES = (
|
||||
@@ -339,11 +342,13 @@ let
|
||||
moon_phase = astronomy['moon_phase']
|
||||
wego = WEATHER_CODES_WEGO[current_condition['weatherCode']]
|
||||
|
||||
tooltip = f"{wego[0]}{weather_description} {temp_f}°\n"
|
||||
tooltip += f"{wego[1]}Feels like: {feels_like_f}°\n"
|
||||
tooltip += f"{wego[2]}Wind: {wind_speed}mph {WIND_DIRECTION[wind_dir]}\n"
|
||||
tooltip += f"{wego[3]}Humidity: {humidity}%\n"
|
||||
tooltip += f"{wego[4]}Moon phase: {moon_phase} " + moon_icon + "\n"
|
||||
current = f"{wego[0]}{weather_description} {temp_f}°\n"
|
||||
feels = f"{wego[1]}Feels like: {feels_like_f}°\n"
|
||||
wind = f"{wego[2]}Wind: {wind_speed}mph {WIND_DIRECTION[wind_dir]}\n"
|
||||
humidityl = f"{wego[3]}Humidity: {humidity}%\n"
|
||||
moon = f"{wego[4]}Moon phase: {moon_phase} " + moon_icon + "\n"
|
||||
|
||||
tooltip = current + feels + wind + humidityl + moon
|
||||
|
||||
return tooltip
|
||||
|
||||
@@ -419,9 +424,12 @@ let
|
||||
current_condition = weather["current_condition"][0]
|
||||
astronomy = weather["weather"][0]['astronomy'][0]
|
||||
|
||||
data["text"] = build_text(current_condition)
|
||||
data["tooltip"] = build_tooltip(current_condition, astronomy, moon_icon)
|
||||
data["tooltip"] += build_forecast(weather["weather"])
|
||||
text = build_text(current_condition)
|
||||
|
||||
tooltip = build_tooltip(current_condition, astronomy, moon_icon) + build_forecast(weather["weather"])
|
||||
|
||||
data["text"] = text
|
||||
data["tooltip"] = tooltip
|
||||
|
||||
return json.dumps(data)
|
||||
|
||||
@@ -430,6 +438,7 @@ let
|
||||
try:
|
||||
print(get_wttr_json())
|
||||
except Exception as e:
|
||||
print("error")
|
||||
print(e)
|
||||
|
||||
main()
|
||||
|
||||
Reference in New Issue
Block a user