diff options
author | Xiao Pan <gky44px1999@gmail.com> | 2023-12-03 06:27:14 -0800 |
---|---|---|
committer | Xiao Pan <gky44px1999@gmail.com> | 2023-12-03 06:27:14 -0800 |
commit | b8a4d9991364e2cc92e5fa03a3a446be28f14ca9 (patch) | |
tree | e7cde8b1b7d1cbac19a5714dd5c5dad4168ed3bf /home/xyz/.local | |
parent | ae50d25589f1a41ac2230887c315cab7bded233a (diff) |
update
Diffstat (limited to 'home/xyz/.local')
-rwxr-xr-x | home/xyz/.local/bin/wtr | 7 |
1 files changed, 6 insertions, 1 deletions
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 |