mirror of
https://github.com/elenapan/dotfiles.git
synced 2026-01-28 03:07:12 +08:00
Add evil coronavirus daemon
This commit is contained in:
parent
6d537988ba
commit
2961e60b0e
3 changed files with 41 additions and 0 deletions
35
config/awesome/evil/coronavirus.lua
Normal file
35
config/awesome/evil/coronavirus.lua
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
-- Provides:
|
||||
-- evil::coronavirus
|
||||
-- cases_total (integer)
|
||||
-- cases_today (integer)
|
||||
-- deaths_total (integer)
|
||||
-- deaths_today (integer)
|
||||
local awful = require("awful")
|
||||
local helpers = require("helpers")
|
||||
local naughty = require("naughty")
|
||||
|
||||
local update_interval = 60 * 60 * 12 -- 12 hours
|
||||
local country = user.coronavirus_country or "usa"
|
||||
|
||||
local coronavirus_script = [[
|
||||
sh -c '
|
||||
country="]]..country..[["
|
||||
|
||||
stats=$(curl "https://corona-stats.online/$country?format=json" 2>/dev/null)
|
||||
|
||||
cases_total="$(echo $stats | jq ".data[0].cases")"
|
||||
cases_today="$(echo $stats | jq ".data[0].todayCases")"
|
||||
deaths_total="$(echo $stats | jq ".data[0].deaths")"
|
||||
deaths_today="$(echo $stats | jq ".data[0].todayDeaths")"
|
||||
|
||||
echo CTOTAL@$cases_total@CTODAY@$cases_today@DTOTAL@$deaths_total@DTODAY@$deaths_today@
|
||||
']]
|
||||
|
||||
helpers.remote_watch(coronavirus_script, update_interval, "/tmp/awesomewm-evil-coronavirus", function(stdout)
|
||||
local cases_total = stdout:match('^CTOTAL@(.*)@CTODAY')
|
||||
local cases_today = stdout:match('CTODAY@(.*)@DTOTAL')
|
||||
local deaths_total = stdout:match('DTOTAL@(.*)@DTODAY')
|
||||
local deaths_today = stdout:match('DTODAY@(.*)@')
|
||||
|
||||
awesome.emit_signal("evil::coronavirus", cases_total, cases_today, deaths_total, deaths_today)
|
||||
end)
|
||||
|
|
@ -12,4 +12,5 @@ require("evil.brightness")
|
|||
-- require("evil.spotify")
|
||||
|
||||
-- Internet access required
|
||||
require("evil.coronavirus")
|
||||
require("evil.weather")
|
||||
|
|
|
|||
|
|
@ -120,6 +120,11 @@ user = {
|
|||
openweathermap_city_id = "yyyyyy",
|
||||
-- > Use "metric" for Celcius, "imperial" for Fahrenheit
|
||||
weather_units = "metric",
|
||||
|
||||
-- >> Coronavirus <<
|
||||
-- Country to check for corona statistics
|
||||
-- Uses the https://corona-stats.online API
|
||||
coronavirus_country = "usa",
|
||||
}
|
||||
-- ===================================================================
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue