2018-08-05 16:54:22 -04:00
|
|
|
require 'cairo'
|
|
|
|
local __cairo_xlib_surface_create = cairo_xlib_surface_create
|
|
|
|
local __cairo_create = cairo_create
|
|
|
|
local __cairo_surface_destroy = cairo_surface_destroy
|
|
|
|
local __cairo_destroy = cairo_destroy
|
2017-07-16 14:50:33 -04:00
|
|
|
|
2021-07-16 23:25:44 -04:00
|
|
|
local ABS_PATH = debug.getinfo(1).source:match("@?(.*/)")
|
|
|
|
package.path = ABS_PATH..'?.lua;'..
|
|
|
|
ABS_PATH..'drawing/?.lua;'..
|
|
|
|
ABS_PATH..'schema/?.lua;'..
|
2021-08-08 15:10:09 -04:00
|
|
|
ABS_PATH..'core/?.lua;'..
|
2021-07-16 23:25:44 -04:00
|
|
|
ABS_PATH..'core/widget/?.lua;'..
|
|
|
|
ABS_PATH..'core/widget/arc/?.lua;'..
|
|
|
|
ABS_PATH..'core/widget/text/?.lua;'..
|
2021-08-08 15:10:09 -04:00
|
|
|
ABS_PATH..'core/widget/timeseries/?.lua;'..
|
2021-07-16 23:25:44 -04:00
|
|
|
ABS_PATH..'core/widget/rect/?.lua;'..
|
2022-07-17 01:25:53 -04:00
|
|
|
ABS_PATH..'core/widget/line/?.lua;'..
|
2022-07-17 12:07:38 -04:00
|
|
|
ABS_PATH..'lib/share/lua/5.4/?.lua;'..
|
|
|
|
ABS_PATH..'lib/share/lua/5.4/?/init.lua;'
|
|
|
|
|
|
|
|
package.cpath = ABS_PATH..'lib/lib/lua/5.4/?.so;'
|
2017-07-20 00:49:24 -04:00
|
|
|
|
2021-08-08 15:58:53 -04:00
|
|
|
local i_o = require 'i_o'
|
2022-07-14 20:13:29 -04:00
|
|
|
local geom = require 'geom'
|
2022-07-16 00:00:06 -04:00
|
|
|
local pure = require 'pure'
|
2021-07-29 22:18:29 -04:00
|
|
|
local system = require 'system'
|
|
|
|
local network = require 'network'
|
|
|
|
local processor = require 'processor'
|
|
|
|
local filesystem = require 'filesystem'
|
|
|
|
local pacman = require 'pacman'
|
|
|
|
local power = require 'power'
|
|
|
|
local readwrite = require 'readwrite'
|
|
|
|
local graphics = require 'graphics'
|
|
|
|
local memory = require 'memory'
|
2022-07-17 18:40:24 -04:00
|
|
|
local compile = require 'compile'
|
|
|
|
local common = require 'common'
|
2022-07-17 12:07:38 -04:00
|
|
|
local yaml = require 'lyaml'
|
2019-10-13 21:05:38 -04:00
|
|
|
|
2021-07-17 21:22:17 -04:00
|
|
|
local draw_dynamic
|
2019-10-11 21:52:10 -04:00
|
|
|
|
2022-07-17 18:40:24 -04:00
|
|
|
local build_main = function(update_interval, config_path)
|
2021-07-17 00:17:22 -04:00
|
|
|
local update_freq = 1 / update_interval
|
2022-07-17 18:40:24 -04:00
|
|
|
local config = yaml.load(i_o.read_file(config_path))
|
|
|
|
local cmods = config.modules
|
2021-07-17 00:17:22 -04:00
|
|
|
|
2022-07-16 00:27:27 -04:00
|
|
|
local main_state = {}
|
|
|
|
|
2022-07-17 12:07:38 -04:00
|
|
|
local mods = {
|
|
|
|
memory = pure.partial(memory, update_freq, cmods.memory),
|
|
|
|
readwrite = pure.partial(readwrite, update_freq, cmods.readwrite),
|
|
|
|
network = pure.partial(network, update_freq),
|
|
|
|
power = pure.partial(power, update_freq, cmods.power),
|
|
|
|
filesystem = pure.partial(filesystem, cmods.filesystem, main_state),
|
|
|
|
system = pure.partial(system, main_state),
|
|
|
|
graphics = pure.partial(graphics, update_freq, cmods.graphics),
|
|
|
|
processor = pure.partial(processor, update_freq, cmods.processor, main_state),
|
|
|
|
pacman = pure.partial(pacman, main_state)
|
|
|
|
}
|
2021-07-17 00:17:22 -04:00
|
|
|
|
2022-07-17 18:40:24 -04:00
|
|
|
local compiled = compile.compile_layout(
|
|
|
|
common(config),
|
2022-07-17 01:25:53 -04:00
|
|
|
geom.make_point(table.unpack(config.layout.anchor)),
|
2022-07-17 12:07:38 -04:00
|
|
|
mods,
|
|
|
|
config.layout.panels
|
2021-07-17 00:17:22 -04:00
|
|
|
)
|
|
|
|
|
2021-08-08 19:56:18 -04:00
|
|
|
local STATS_FILE = '/tmp/.conky_pacman'
|
2021-07-17 16:59:06 -04:00
|
|
|
|
2022-07-17 18:40:24 -04:00
|
|
|
return function(cr, _updates)
|
2022-07-16 00:00:06 -04:00
|
|
|
main_state.trigger10 = _updates % (update_freq * 10)
|
|
|
|
main_state.pacman_stats = i_o.read_file(STATS_FILE)
|
|
|
|
|
|
|
|
compiled.static(cr)
|
2022-07-16 00:27:27 -04:00
|
|
|
compiled.update()
|
2022-07-16 00:00:06 -04:00
|
|
|
compiled.dynamic(cr)
|
2021-07-17 00:17:22 -04:00
|
|
|
end
|
2021-07-16 23:25:44 -04:00
|
|
|
end
|
|
|
|
|
2022-07-17 18:40:24 -04:00
|
|
|
function conky_start(update_interval)
|
|
|
|
conky_set_update_interval(update_interval)
|
|
|
|
|
|
|
|
draw_dynamic = build_main(update_interval, ABS_PATH..'config.yml')
|
|
|
|
end
|
|
|
|
|
2021-07-17 21:22:17 -04:00
|
|
|
local updates = -2 -- this accounts for the first few spazzy iterations
|
|
|
|
|
2018-08-05 16:54:22 -04:00
|
|
|
function conky_main()
|
2018-08-05 04:05:38 -04:00
|
|
|
local _cw = conky_window
|
|
|
|
if not _cw then return end
|
2018-08-05 11:08:37 -04:00
|
|
|
|
2018-08-05 16:54:22 -04:00
|
|
|
local cs = __cairo_xlib_surface_create(_cw.display, _cw.drawable,
|
2019-10-12 18:14:38 -04:00
|
|
|
_cw.visual, 1920, 1080)
|
2018-08-05 04:05:38 -04:00
|
|
|
local cr = __cairo_create(cs)
|
|
|
|
updates = updates + 1
|
2019-09-01 15:34:10 -04:00
|
|
|
|
2021-07-17 21:22:17 -04:00
|
|
|
draw_dynamic(cr, updates)
|
2019-09-01 15:34:10 -04:00
|
|
|
|
2018-08-05 04:05:38 -04:00
|
|
|
__cairo_surface_destroy(cs)
|
|
|
|
__cairo_destroy(cr)
|
2016-08-11 23:25:56 -04:00
|
|
|
end
|