2021-08-08 19:12:31 -04:00
|
|
|
local i_o = require 'i_o'
|
2022-07-14 20:20:27 -04:00
|
|
|
local pure = require 'pure'
|
2021-08-08 19:12:31 -04:00
|
|
|
local common = require 'common'
|
2021-07-29 22:18:29 -04:00
|
|
|
local geometry = require 'geometry'
|
2017-07-19 00:36:15 -04:00
|
|
|
|
2022-07-14 20:13:29 -04:00
|
|
|
return function(point)
|
2021-07-18 00:06:49 -04:00
|
|
|
local TEXT_SPACING = 20
|
|
|
|
|
|
|
|
local __string_match = string.match
|
|
|
|
|
2022-07-14 20:20:27 -04:00
|
|
|
local mk_stats = function(y)
|
|
|
|
local obj = common.make_text_rows(
|
|
|
|
point.x,
|
|
|
|
y,
|
|
|
|
geometry.SECTION_WIDTH,
|
|
|
|
TEXT_SPACING,
|
|
|
|
{'Kernel', 'Uptime', 'Last Upgrade', 'Last Sync'}
|
|
|
|
)
|
2022-07-16 00:00:06 -04:00
|
|
|
local update = function(state)
|
2022-07-14 20:20:27 -04:00
|
|
|
local last_update, last_sync
|
2022-07-16 00:00:06 -04:00
|
|
|
if state.pacman_stats then
|
|
|
|
last_update, last_sync = __string_match(
|
|
|
|
state.pacman_stats,
|
|
|
|
"^%d+%s+([^%s]+)%s+([^%s]+).*"
|
|
|
|
)
|
2022-07-14 20:20:27 -04:00
|
|
|
end
|
|
|
|
-- TODO this doesn't need to be update every time
|
|
|
|
common.text_rows_set(obj, 1, i_o.conky('$kernel'))
|
|
|
|
common.text_rows_set(obj, 2, i_o.conky('$uptime'))
|
|
|
|
common.text_rows_set(obj, 3, last_update)
|
|
|
|
common.text_rows_set(obj, 4, last_sync)
|
2021-07-18 00:06:49 -04:00
|
|
|
end
|
2022-07-14 20:20:27 -04:00
|
|
|
local static = pure.partial(common.text_rows_draw_static, obj)
|
|
|
|
local dynamic = pure.partial(common.text_rows_draw_dynamic, obj)
|
2022-07-16 00:00:06 -04:00
|
|
|
return common.mk_acc(
|
|
|
|
geometry.SECTION_WIDTH,
|
|
|
|
TEXT_SPACING * 3,
|
|
|
|
update,
|
|
|
|
static,
|
|
|
|
dynamic
|
|
|
|
)
|
2018-08-05 11:08:37 -04:00
|
|
|
end
|
2017-07-19 00:36:15 -04:00
|
|
|
|
2022-07-14 20:20:27 -04:00
|
|
|
return common.reduce_blocks_(
|
2022-07-14 22:49:08 -04:00
|
|
|
'SYSTEM',
|
|
|
|
point,
|
|
|
|
geometry.SECTION_WIDTH,
|
|
|
|
{common.mk_block(mk_stats, true, 0)}
|
2022-07-14 20:20:27 -04:00
|
|
|
)
|
2021-07-17 00:17:22 -04:00
|
|
|
end
|