Last active
April 3, 2020 07:35
-
-
Save Bouni/03e8d43771d9b62ee392b2266fb2875f to your computer and use it in GitHub Desktop.
A Corona Virus status plugin for py3status bar
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # -*- 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