-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathworld_population.lua
executable file
·41 lines (31 loc) · 1.1 KB
/
world_population.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/env lua
-- deps: get-world-population
handle = io.popen("get-world-population")
result = handle:read("*a")
handle:close()
--require 'pl.pretty'.dump(result)
json = require("json")
data = json.decode(result)
timestamp = os.date("%H:%M", data['timestamp'])
conky_text = [[
${alignc}${color9} %s
${alignc}${color7}Current World Population${color}
${alignc}${font size=18}${color4}%s${color}${font}
${color9}${goto 50}today${goto 105}this year${color}
${color9}births${color2}${goto 50}%s${goto 105}%s
${color9}deaths${color7}${goto 50}%s${goto 105}%s
${color9}growth${color6}${goto 50}%s${goto 105}%s
]]
if data then
io.write((conky_text):format(timestamp,
data["current_population"],
data["births_today"],
data["births_year"],
data["deaths_today"],
data["deaths_year"],
data["absolute_growth"],
data["absolute_growth_year"])
)
else
io.write("[E] data is empty!")
end