Show max/min for weather and difference to previous day in covid, fix mpv fds
This commit is contained in:
parent
6db1cab946
commit
961bc66584
|
@ -1,2 +1,2 @@
|
||||||
typeset -g _cprompts_covid=$(curl -sL https://api.covid19api.com/country/${REPLY:-germany} | jq -e '. |= sort_by (.Date) | .[-1].Active')
|
typeset -g _cprompts_covid=($(curl -sL https://api.covid19api.com/country/${REPLY:-germany} | jq -e '. |= sort_by (.Date) | .[-1,-2].Active'))
|
||||||
[ ! -z $_cprompts_covid ] && print ${_cprompts_covid} > $tmpfile
|
[ ! -z $_cprompts_covid[1] ] && <<< ${_cprompts_covid} > $tmpfile
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
local REPLY
|
local REPLY
|
||||||
zstyle -s ':custom:prompts:weather' location REPLY
|
zstyle -s ':custom:prompts:weather' location REPLY
|
||||||
local result=$(curl -sL https://www.metaweather.com/api/location/${REPLY:-1339615}/ | jq -e '.consolidated_weather[0] | {"temp": .the_temp, "icon": .weather_state_abbr}')
|
local result=$(curl -sL https://www.metaweather.com/api/location/${REPLY:-1339615}/ | jq -e '.consolidated_weather[0] | {"temp": {"min": .min_temp, "max": .max_temp}, "icon": .weather_state_abbr}')
|
||||||
if [ ! -z $result ]; then
|
if [ ! -z $result ]; then
|
||||||
local ico=$(print $result | jq -r '.icon')
|
local ico=$(print $result | jq -r '.icon')
|
||||||
typeset -g _cprompts_weather=($(jq -r '.temp' <<< $result) ${colors[$ico]:-white} ${icons[${ico:-X}]})
|
typeset -g _cprompts_weather=($(jq -r '.temp.min' <<< $result) $(jq -r '.temp.max' <<< $result) ${colors[$ico]:-white} ${icons[${ico:-X}]})
|
||||||
print ${_cprompts_weather%%.*} > $tmpfile
|
print ${_cprompts_weather} > $tmpfile
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -8,7 +8,7 @@ if [ ! -v _cprompts_covid ]; then
|
||||||
if [ ${stats[1]:-0} -lt $(($epochtime[1]-86400)) ]; then
|
if [ ${stats[1]:-0} -lt $(($epochtime[1]-86400)) ]; then
|
||||||
cprompts:cache:async:covid &!
|
cprompts:cache:async:covid &!
|
||||||
else
|
else
|
||||||
typeset -g _cprompts_covid=$(< $tmpfile)
|
typeset -g _cprompts_covid=($(< $tmpfile))
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
[ -v _cprompts_covid ] && p10k segment -b red -i '' -t "${_cprompts_covid:-unknown}"
|
[ -v _cprompts_covid ] && p10k segment -b red -i '' -t "${_cprompts_covid[1]:-unknown} ($(( ${_cprompts_covid[1]:-0} - ${_cprompts_covid[2]:-0} )))"
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
local REPLY
|
local REPLY
|
||||||
zsocket ~/.mpvsock 2>&1 >/dev/null || return
|
zsocket ~/.mpvsock 2>/dev/null || return
|
||||||
typeset -ga _cprompts_mpv=($REPLY)
|
typeset -ga _cprompts_mpv=($REPLY)
|
||||||
_cprompts_mpv[2]="${${$(print -u $_cprompts_mpv[1] '{ "command": ["get_property", "media-title"] }' && read -Eu $_cprompts_mpv[1])#*\"data\"([^[:print:]])#:([^[:print:]])#\"}%%(\"~\\\")*}"
|
_cprompts_mpv[2]="${${$(print -u $_cprompts_mpv[1] '{ "command": ["get_property", "media-title"] }' && read -Eu $_cprompts_mpv[1])#*\"data\"([^[:print:]])#:([^[:print:]])#\"}%%(\"~\\\")*}"
|
||||||
|
exec {REPLY}>&-
|
||||||
[ -z $_cprompts_mpv[2] ] || p10k segment -b magenta -i '' -t "${_cprompts_mpv[2]:0:20}$([ ${#_cprompts_mpv[2]} -gt 20 ] && print ...)"
|
[ -z $_cprompts_mpv[2] ] || p10k segment -b magenta -i '' -t "${_cprompts_mpv[2]:0:20}$([ ${#_cprompts_mpv[2]} -gt 20 ] && print ...)"
|
||||||
|
|
|
@ -34,4 +34,4 @@ if [ ! -v _cprompts_weather ]; then
|
||||||
typeset -g _cprompts_weather=($(< $tmpfile))
|
typeset -g _cprompts_weather=($(< $tmpfile))
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
[ -v _cprompts_weather ] && p10k segment -b ${_cprompts_weather[2]:-white} -i ${_cprompts_weather[3]:-\?} -t "${_cprompts_weather[1]:-unknown}"
|
[ -v _cprompts_weather ] && p10k segment -b ${_cprompts_weather[3]:-white} -i ${_cprompts_weather[4]:-\?} -t "${_cprompts_weather[1]:-unknown} - ${_cprompts_weather[2]:-unknown}"
|
||||||
|
|
Loading…
Reference in New Issue