From 0db7375055abdade67ea02291e5961a7733c4ab6 Mon Sep 17 00:00:00 2001 From: kat witch Date: Sat, 13 Feb 2021 01:46:28 +0000 Subject: [PATCH] Weather script changes. --- config/users/kat/waybar.nix | 1 + scripts/weather.py | 12 ++++++------ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/config/users/kat/waybar.nix b/config/users/kat/waybar.nix index 65435d31..e923706d 100644 --- a/config/users/kat/waybar.nix +++ b/config/users/kat/waybar.nix @@ -30,6 +30,7 @@ in { "custom/weather" = { format = "{}"; interval = 3600; + on-click = "xdg-open 'https://google.com/search?q=weather'"; exec = "nix-shell --command 'python ${ ../../../scripts/weather.py } ${secrets.profiles.sway.city} ${secrets.profiles.sway.api_key}' ${ diff --git a/scripts/weather.py b/scripts/weather.py index ca59ec03..d0454ee3 100644 --- a/scripts/weather.py +++ b/scripts/weather.py @@ -25,11 +25,11 @@ weather_icons = { "Tornado": "" } -def degrees_to_cardinal(d): - dirs = ["N", "NNE", "NE", "ENE", "E", "ESE", "SE", "SSE", - "S", "SSW", "SW", "WSW", "W", "WNW", "NW", "NNW"] - ix = int((d + 11.25)/22.5) - return dirs[ix % 16] +#def degrees_to_cardinal(d): +# dirs = ["N", "NNE", "NE", "ENE", "E", "ESE", "SE", "SSE", +# "S", "SSW", "SW", "WSW", "W", "WNW", "NW", "NNW"] +# ix = int((d + 11.25)/22.5) +# return dirs[ix % 16] response = requests.get(url) data = json.loads(response.text) @@ -40,7 +40,7 @@ weather_icon = weather_icons[condition] temperature = f"{round(data['main']['temp'])}°C" feels_like_temperature = f"{round(data['main']['feels_like'])}°C" humidity = f"{data['main']['humidity']}%" -wind = f"{round(data['wind']['speed'])}m/s {degrees_to_cardinal(data['wind']['deg'])}" +wind = f"{round(data['wind']['speed'])}m/s" # {degrees_to_cardinal(data['wind']['deg'])}" end_string = f"{weather_icon} {temperature} {feels_like_temperature} {humidity} {wind}" print(end_string)