From b8a4d9991364e2cc92e5fa03a3a446be28f14ca9 Mon Sep 17 00:00:00 2001 From: Xiao Pan Date: Sun, 3 Dec 2023 06:27:14 -0800 Subject: update --- home/xyz/.local/bin/wtr | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'home/xyz/.local') diff --git a/home/xyz/.local/bin/wtr b/home/xyz/.local/bin/wtr index 5b385d64..c9907d93 100755 --- a/home/xyz/.local/bin/wtr +++ b/home/xyz/.local/bin/wtr @@ -1,7 +1,8 @@ #!/bin/sh # https://github.com/open-meteo/open-meteo -curl -s -G -d "latitude=${1:-37.34}" -d "longitude=${2:--121.89}" -d 'daily=weathercode,temperature_2m_max,temperature_2m_min' -d 'timezone=auto' 'https://api.open-meteo.com/v1/forecast' | jq -r '[.daily|.time, .weathercode, .temperature_2m_max, .temperature_2m_min]|transpose|.[]|@tsv' | while read -r time code max min; do +i=0 +curl -s -G -d "latitude=${1:-37.34}" -d "longitude=${2:--121.89}" -d 'daily=weathercode,temperature_2m_max,temperature_2m_min,sunrise,sunset' -d 'timezone=auto' 'https://api.open-meteo.com/v1/forecast' | jq -r '[.daily|.time, .weathercode, .temperature_2m_max, .temperature_2m_min, .sunrise, .sunset]|transpose|.[]|@tsv' | while read -r time code max min sunrise sunset; do # https://open-meteo.com/en/docs case "$code" in 0) code='clear sky';; @@ -34,5 +35,9 @@ curl -s -G -d "latitude=${1:-37.34}" -d "longitude=${2:--121.89}" -d 'daily=weat 99) code='thunderstorm with heavy hail';; *) exit 1;; esac + if [ "$i" -ne 1 ]; then + printf 'sunrise: %s | sunset: %s\n' "${sunrise#*T}" "${sunset#*T}" + i=1 + fi printf '%s\t%s\t%s\t%s\n' "${time#*-}" "$max" "$min" "$code" done -- cgit v1.2.3-70-g09d2