diff --git a/fetch-covid.zsh b/fetch-covid.zsh new file mode 100755 index 0000000..bae1beb --- /dev/null +++ b/fetch-covid.zsh @@ -0,0 +1,5 @@ +#!/bin/zsh + +([ -v commands\[curl\] ] && [ -v commands\[jq\] ]) || return +typeset -g _cprompts_covid=($(curl -sL https://api.covid19api.com/country/${1:-germany} | jq -e '. |= sort_by (.Date) | .[-1,-2].Active')) +[ ! -z $_cprompts_covid[1] ] && <<< ${_cprompts_covid} > ${2:-~/.cache/covid} diff --git a/fetch-weather.zsh b/fetch-weather.zsh new file mode 100755 index 0000000..7f18b98 --- /dev/null +++ b/fetch-weather.zsh @@ -0,0 +1,13 @@ +#!/bin/zsh + +([ -v commands\[curl\] ] && [ -v commands\[jq\] ]) || return +zmodload zsh/mathfunc +typeset -A icons +typeset -A colors +icons=([c]='' [lc]='' [hc]='' [s]='🌢' [lr]='🌢' [hr]='' [sn]='' [t]='' [h]='' [sl]='') +colors=([c]="yellow" [lc]="yellow" [hc]="cyan" [s]="yellow" [lr]="cyan" [hr]="blue" [t]="white" [h]="white" [sl]="blue" [sn]="white") +result=$(curl -sL https://www.metaweather.com/api/location/${1:-1339615}/ | jq -e '.consolidated_weather[0] | {"temp": .the_temp, "hum": .humidity, "icon": .weather_state_abbr}') +if [ ! -z $result ]; then + ico=$(<<< "$result" jq -r '.icon') + <<< "$(( int(rint($(jq -r '.temp' <<< $result))) )) ${colors[$ico]:-white} ${icons[$ico]:-X} $(( int(rint($(jq -r '.hum' <<< $result))) ))" > ${2:-~/.cache/weather} +fi