diff options
| author | Robert Günzler <r@gnzler.io> | 2021-02-23 13:36:27 +0100 |
|---|---|---|
| committer | Robert Günzler <r@gnzler.io> | 2021-04-26 02:09:45 +0200 |
| commit | 4b71908c30807c9d726e83378e04ccae28dff334 (patch) | |
| tree | ab3c37125a69803ffdaba7cdcac9014c437f3215 /.config/waybar/modules/covid.sh | |
| parent | 6cb604cdeb78b151d7e179d4f34f00101c912282 (diff) | |
waybar: update 2021-02-23T13:36:34Z+01:00
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" |