reisp01 / corona-conky2

Coronavirus stats in conky, now with more formatting
GNU General Public License v3.0
1 stars 0 forks source link

Different approach using a single bash file #1

Closed Strykar closed 4 years ago

Strykar commented 4 years ago

My bash file -

:~ cat ~/conky/conky-grapes/corona.sh 

#!/bin/bash

# Estimated cases, wld=World, ind=India
_wldest () { printf "%'d" "$(curl -s https://corona.lmao.ninja/v2/all | jq -r '.deaths * 1000')"; }
_indest () { printf "%'d" "$(curl -s https://corona.lmao.ninja/v2/countries/in | jq -r '.deaths * 1000')"; }

_indc() { printf "%'d" "$(curl -s https://corona.lmao.ninja/v2/countries/in | jq -r .cases)"; }
_indd() { printf "%'d" "$(curl -s https://corona.lmao.ninja/v2/countries/in | jq -r .deaths)"; }

_wldc() { printf "%'d" "$(curl -s https://corona.lmao.ninja/v2/all | jq -r .cases)"; }
_wldd() { printf "%'d" "$(curl -s https://corona.lmao.ninja/v2/all | jq -r .deaths)"; }

case "$1" in
'indest')
  _indest
  ;;
'wldest')
  _wldest
  ;;
'indc')
  _indc
  ;;
'indd')
  _indd
  ;;
'wldc')
  _wldc
  ;;
'wldd')
  _wldd
  ;;
*)
  echo "usage $0 indest|wldest|indc|indd|wldc|wldd"

Snipped conky.conf with text formatted for my display:

${color #c0fb2d}${font Noto Mono:size=22}☣${font}${color}${font Noto Mono:size=10:bold}Coronavirus${font}
India:          ${texeci 60 /home/strykar/conky/conky-grapes/corona.sh indest}     Estimated infections
Worldwide:  ${texeci 60 /home/strykar/conky/conky-grapes/corona.sh wldest} Estimated infections
India:          ${texeci 60 /home/strykar/conky/conky-grapes/corona.sh indc}        Cases | ${texeci 60 /home/strykar/conky/conky-grapes/corona.sh indd}     Deaths
Worldwide:  ${texeci 60 /home/strykar/conky/conky-grapes/corona.sh wldc}     Cases | ${texeci 60 /home/strykar/conky/conky-grapes/corona.sh wldd} Deaths

This is what it ends up looking like - https://i.imgur.com/Njo0Rza.png

If you fancy this approach, I can clean it up and send a PR.

reisp01 commented 4 years ago

I incorporated your changes (along with other stuff like v3 of the API) into this new version. Please let me know if I've credited you as you wish. Thanks!