conky-config/drawing/System.lua

45 lines
1.2 KiB
Lua
Raw Normal View History

local Util = require 'Util'
local Common = require 'Common'
local Geometry = require 'Geometry'
2017-07-19 00:36:15 -04:00
return function()
local TEXT_SPACING = 20
local __string_match = string.match
local header = Common.Header(
Geometry.LEFT_X,
Geometry.TOP_Y,
Geometry.SECTION_WIDTH,
'SYSTEM'
)
local rows = Common.initTextRows(
Geometry.LEFT_X,
header.bottom_y,
Geometry.SECTION_WIDTH,
TEXT_SPACING,
{'Kernel', 'Uptime', 'Last Upgrade', 'Last Sync'}
)
local draw_static = function(cr)
Common.drawHeader(cr, header)
Common.text_rows_draw_static(rows, cr)
end
local draw_dynamic = function(cr, pacman_stats)
local last_update, last_sync = "N/A", "N/A"
if pacman_stats then
last_update, last_sync = __string_match(pacman_stats, "^%d+%s+([^%s]+)%s+([^%s]+).*")
end
-- TODO this doesn't need to be update every time
2021-07-26 23:45:54 -04:00
Common.text_rows_set(rows, 1, Util.conky('$kernel'))
Common.text_rows_set(rows, 2, Util.conky('$uptime'))
Common.text_rows_set(rows, 3, last_update)
Common.text_rows_set(rows, 4, last_sync)
Common.text_rows_draw_dynamic(rows, cr)
2018-08-05 11:08:37 -04:00
end
2017-07-19 00:36:15 -04:00
return {static = draw_static, dynamic = draw_dynamic}
end