diff options
Diffstat (limited to '.config/waybar/modules/covid.sh')
| -rwxr-xr-x | .config/waybar/modules/covid.sh | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/.config/waybar/modules/covid.sh b/.config/waybar/modules/covid.sh new file mode 100755 index 0000000..b30321c --- /dev/null +++ b/.config/waybar/modules/covid.sh @@ -0,0 +1,43 @@ +#!/bin/sh + +set -e +[ -n "$DEBUG" ] && { set -x; curl_args='-v'; } + +# incidence = (sumCasesLast7Days / EWZ) * 100000 +lat=52.54 +lon=13.44 +fields='GEN,RS,EWZ,EWZ_BL,BL_ID,cases,cases_per_100k,cases7_per_100k,cases7_bl_per_100k,last_update,BL,IBZ' +uri="https://services7.arcgis.com/mOBPykOjAyBO2ZKk/arcgis/rest/services/RKI_Landkreisdaten/FeatureServer/0/query?where=1%3D1&outFields=${fields}&geometry=${lon}%2C${lat}&geometryType=esriGeometryPoint&inSR=4326&spatialRel=esriSpatialRelWithin&returnGeometry=false&outSR=4326&f=json" + +_data=$(curl -sSL -H 'Accept: application/json' ${curl_args} ${uri} | jq -r '.features[0].attributes') +loc=$(printf "${_data}" | jq -r '.GEN') +incidence_f=$(printf "%.1f" $(printf "${_data}" | jq -r '.cases7_bl_per_100k')) +incidence_i=$(printf "%.0f" "${incidence_f}") + +color='green' +if [ "${incidence_i}" -eq "0" ]; then + color='gray' +fi +if [ "${incidence_i}" -gt "1" ]; then + color='green' +fi +if [ "${incidence_i}" -gt "25" ]; then + color='yellow' +fi +if [ "${incidence_i}" -gt "35" ]; then + color='orange' +fi +if [ "${incidence_i}" -gt "50" ]; then + color='red' +fi +if [ "${incidence_i}" -gt "100" ]; then + color='darkred' +fi +if [ "${incidence_i}" -gt "250" ]; then + color='darkdarkred' +fi + +jq -nr \ + --arg "if" "${incidence_f}" \ + --arg "ii" "${incidence_i}" \ + "{ text: \$if, percentage: \$ii, class: \"${color}\", alt: \"${color}\", tooltip: \"7 Tage Inzidenz für \\n${loc}\" } | @text" |