Skip to content

Instantly share code, notes, and snippets.

@Bouni
Last active April 3, 2020 07:35
Show Gist options
  • Select an option

  • Save Bouni/03e8d43771d9b62ee392b2266fb2875f to your computer and use it in GitHub Desktop.

Select an option

Save Bouni/03e8d43771d9b62ee392b2266fb2875f to your computer and use it in GitHub Desktop.
A Corona Virus status plugin for py3status bar
# -*- coding: utf-8 -*-
"""
A corona virus status plugin for py3status.
Save this into ~/.config/py3status/modules/corona.py
This is static for Germany and gets its data from https://github.com/sagarkarira/coronavirus-tracker-cli
Can be easily changed for a different country by changing the requests url below.
"""
import requests
class Py3status:
cache_timeout = 600
def corona(self):
r = requests.get("https://corona-stats.online/Germany?format=json")
data = r.json().get("data", {})
cases_icon = "πŸ‡©πŸ‡ͺ😷"
critical_icon = "😰"
death_icon = "πŸ’€"
recoverd_icon = "😊"
return {
"full_text": f'{cases_icon} {data[0].get("cases")} ({data[0].get("todayCases")}) / {critical_icon} {data[0].get("critical")} / {death_icon} {data[0].get("deaths")} ({data[0].get("todayDeaths")}) / {recoverd_icon} {data[0].get("recovered")}',
"cached_until": self.py3.time_in(self.cache_timeout),
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment