Polybar Covid Tracker


I installed Arco Linux on my laptop because I wanted to learn more about Arch Linux and Arco gives you a nice and laid back learning path. Phase one of Arco comes with essential things preinstalled and Calamares installer, where you can choose what software to preinstall. It gives you plethora of choice of terminals, browsers, window managers, themes, etc. I’d say it’s a pretty good way to learn Arch around.

Arco, by default, comes with Openbox, i3 and Xfce. I wanted to learn tiling windows managers so, obviously I chose i3 as my WM. (Your choiceof wm doesn’t get you locked in, you can choose it on the login screen). i3 comes with Polybar enabled out of the box.

of course I wanted to tweak it

There was already a Polybar module for tracking Covid cases but it tracks global cases, deaths and recoveries. What is more relevant I think, is trackin cases in the the country you live in.

i forked it

So it would show local cases, deaths and recoveries with daily trends. It was the first time I edited a bash script and it’s probably not that efficient.

the script

#! /usr/bin/bash

# ===================================================================== #
#  file: covid_tracker.sh                                               #
#  Fetch coronavirus progression data from the Free Covid19 API at      #
#  https://disease.sh                                                   #
# ===================================================================== #

res=$(curl -sf "$URL")

if [ -z "$res" ]; then
    echo " Impossible to fetch data. "
    return 1

nb_confirmed=$(jq '.["cases"]' <<< $res)
nb_death=$(jq '.["deaths"]' <<< $res)
nb_recovered=$(jq '.["recovered"]' <<< $res)
nb_todayCases=$(jq '.["todayCases"]' <<< $res)
nb_todayDeaths=$(jq '.["todayDeaths"]' <<< $res)
nb_todayRecovered=$(jq '.["todayRecovered"]' <<< $res)

echo "  $nb_confirmed (+$nb_todayCases) | $nb_death (+$nb_todayDeaths) |  $nb_recovered (+$nb_todayRecovered) "

It’s pretty simple. On the line where I echo, I used emojis to liven the things up and it might not show up for you (idk if Github supports it).

how does it look

Covid Tracker Pic

how to install it

clone my repo

cd /.config/polybar/scripts
git clone https://github.com/larryare/polybar_covid_tracker_v2.git covid

edit your Polybar config

First, backup your ~/.config/polybar/config with

cd ./config/polybar
cp config config.backup

After that, copy contents of covid_module.bar to your Polybar config file using Vim or some different program.

You also have to set script location, so change this line:

exec = "$POLYBAR_SCRIPTS/polybar_covid_tracker/covid_tracker.sh"

into this (if you followed every step as shown here)

exec = "~/.config/polybar/modules/polybar_covid_tracker/covid_tracker.sh"

Then just reload your config (At least in Arco Linux it’s as simple as doing Super + Shift + R) and voila!

wait, why am I looking at random numbers

Vim into the script (or use any other text editor (I really don’t care))

vim ~/.config/polybar/.../covid_tracker.sh

and edit this line:


So it would be your countries’ code from ISO3166 country list.

here /countries/lt is the code.

For example if you’re in France, it’d be


That’s pretty much it.

closing remarks

Obligatory - I don’t know what I’m doing. It works for me and should also work for you. It’s actually the first time I’ve used an API. There’s probably a more elegant way of adding modules to Polybar (with using environmental variables). Someone could teach me about that to be honest.


514 Words

2020-09-02 20:09 +0000