conky-config/drawing/System.lua

45 lines
1.0 KiB
Lua
Raw Normal View History

local M = {}
local Util = require 'Util'
local Common = require 'Common'
2017-07-19 00:36:15 -04:00
local __string_match = string.match
local _TEXT_SPACING_ = 20
local header = Common.Header(
_G_INIT_DATA_.LEFT_X,
_G_INIT_DATA_.TOP_Y,
_G_INIT_DATA_.SECTION_WIDTH,
'SYSTEM'
)
local rows = Common.initTextRows(
_G_INIT_DATA_.LEFT_X,
header.bottom_y,
_G_INIT_DATA_.SECTION_WIDTH,
_TEXT_SPACING_,
{'Kernel', 'Uptime', 'Last Upgrade', 'Last Sync'}
)
2017-07-19 00:36:15 -04:00
_TEXT_SPACING_ = nil
M.draw_static = function(cr)
Common.drawHeader(cr, header)
Common.text_rows_draw_static(rows, cr)
end
M.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]+).*")
2018-08-05 11:08:37 -04:00
end
Common.text_rows_set(rows, cr, 1, Util.conky('$kernel'))
Common.text_rows_set(rows, cr, 2, Util.conky('$uptime'))
Common.text_rows_set(rows, cr, 3, last_update)
Common.text_rows_set(rows, cr, 4, last_sync)
Common.text_rows_draw_dynamic(rows, cr)
2017-07-19 00:36:15 -04:00
end
return M