forked from takattila/Clock-With-Weather-Conky
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.lua
46 lines (36 loc) · 1.18 KB
/
main.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
42
43
44
45
46
require 'cairo'
draw = require "draw"
json = require "json"
theme = require "theme"
utils = require "utils"
settings = {
appearance = require('themes.appearance.' .. theme.appearance.name .. '.appearance').appearance,
weather = require('themes.weather.' .. theme.weather.name .. '.weather').weather,
system = theme.system,
}
print("-> appearance --------- : " .. './themes/' .. theme.appearance.name .. '/appearance.lua')
print("-> weather ------------ : " .. './themes/' .. theme.weather.name .. '/weather.lua')
print("-> use 12 hour format - : " .. tostring(settings.system.hour_format_12))
assert(os.setlocale(settings.system.locale))
function conky_main()
if conky_window == nil then return end
local cs = cairo_xlib_surface_create(
conky_window.display,
conky_window.drawable,
conky_window.visual,
conky_window.width,
conky_window.height
)
local cr = cairo_create(cs)
if utils.is_set_api_key(cr) then
local weather_json = utils.get_weather_json()
if weather_json ~= "" then
local obj = json.decode(weather_json)
if utils.check_api_response_status(cr, obj) then
draw.elements(cr, obj)
cairo_surface_destroy(cs)
cairo_destroy(cr)
end
end
end
end