From eb7466c9ebf66ba217a9b3aa283bb116fcd3b66f Mon Sep 17 00:00:00 2001 From: 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> Date: Mon, 27 Jan 2025 22:16:46 +1100 Subject: [PATCH] hyprlock: weather use shell weather Use cached weather from shell if available, otherwise use wttr.in --- scripts/weather.fish | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/scripts/weather.fish b/scripts/weather.fish index e576710..a21597e 100755 --- a/scripts/weather.fish +++ b/scripts/weather.fish @@ -1,14 +1,13 @@ #!/bin/fish -set -q XDG_CACHE_HOME && set cache $XDG_CACHE_HOME || set cache ~/.cache -set cache $cache/caelestia/weather.txt +set -q XDG_CACHE_HOME && set -l cache $XDG_CACHE_HOME || set -l cache ~/.cache +set -l cache $cache/caelestia/weather.json -set format '\(.weatherDesc[0].value) • \(.temp_C)°C | UV \(.uvIndex) • 💨 \(.windspeedKmph)km/h' - -set city (curl ipinfo.io | jq -r '.city') -set weather (curl "wttr.in/$city?format=j1" | jq -er '.current_condition[0] | "'$format'"' || cat $cache) - -if test -n weather - echo $weather > $cache - echo $weather +if test -f $cache + jq -r '.current | "\(.condition.text) • \(.temp_c)°C | UV \(.uv) •  \(.wind_kph) kph"' $cache + exit end + +set -l format '\(.weatherDesc[0].value) • \(.temp_C)°C | UV \(.uvIndex) •  \(.windspeedKmph) kph' +set -l city (curl ipinfo.io | jq -r '.city') +curl "wttr.in/$city?format=j1" | jq -er '.current_condition[0] | "'$format'"'