diff options
| author | Xiao Pan <gky44px1999@gmail.com> | 2024-01-09 04:09:59 -0800 | 
|---|---|---|
| committer | Xiao Pan <gky44px1999@gmail.com> | 2024-01-09 04:09:59 -0800 | 
| commit | 5eb0dbf136a9ad582192e003b7573a080514f063 (patch) | |
| tree | 84d3a44749b1b2db50b39504ab7690a15b699e8d /wtr | |
init from config_local_arch personal shell scripts
git log history see https://git.flylightning.xyz/config_local_arch/tree/home/xyz/.local/bin?id=d266c511cffb7eeb20bf1e4610d9d32557b7d0e6
Diffstat (limited to 'wtr')
| -rwxr-xr-x | wtr | 43 | 
1 files changed, 43 insertions, 0 deletions
| @@ -0,0 +1,43 @@ +#!/bin/sh + +# https://github.com/open-meteo/open-meteo +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';; +		1) code='mainly clear';; +		2) code='partly cloudy';; +		3) code=overcast;; +		45) code=fog;; +		48) code='depositing rime fog';; +		51) code='light drizzle';; +		53) code='moderate drizzle';; +		55) code='dense drizzle';; +		56) code='light freezing drizzle';; +		57) code='dense freezing drizzle';; +		61) code='slight rain';; +		63) code='moderate rain';; +		65) code='heavy rain';; +		66) code='light freeze rain';; +		67) code='heavy freeze rain';; +		71) code='slight snow fall';; +		73) code='moderate snow fall';; +		75) code='heavy snow fall';; +		77) code='snow grains';; +		80) code='slight rain showers';; +		81) code='moderate rain showers';; +		82) code='violent rain showers';; +		85) code='slight snow showers';; +		86) code='heavy snow showers';; +		95) code='slight or moderate thunderstorm';; +		96) code='thunderstorm with slight hail';; +		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 | 
