ENH make kernel part of the static image

This commit is contained in:
Nathan Dwarshuis 2019-10-13 21:13:00 -04:00
parent 68faa2d3f3
commit b1ad4fcfa7
1 changed files with 14 additions and 12 deletions

View File

@ -9,11 +9,6 @@ local __string_match = string.match
local _TEXT_SPACING_ = 20 local _TEXT_SPACING_ = 20
local extract_date = function(cmd)
local yyyy, mm_dd = __string_match(Util.execute_cmd(cmd), '%[(%d-)%-(%d-%-%d-)%s')
return mm_dd..'-'..yyyy
end
local header = _G_Widget_.Header{ local header = _G_Widget_.Header{
x = _G_INIT_DATA_.LEFT_X, x = _G_INIT_DATA_.LEFT_X,
y = _G_INIT_DATA_.TOP_Y, y = _G_INIT_DATA_.TOP_Y,
@ -30,33 +25,40 @@ local labels = _G_Widget_.TextColumn{
'Last Upgrade', 'Last Upgrade',
'Last Sync' 'Last Sync'
} }
local kernel = _G_Widget_.Text{
x = _G_INIT_DATA_.LEFT_X + _G_INIT_DATA_.SECTION_WIDTH,
y = header.bottom_y,
x_align = 'right',
text = Util.conky('$kernel'),
text_color = _G_Patterns_.BLUE
}
local info = _G_Widget_.TextColumn{ local info = _G_Widget_.TextColumn{
x = _G_INIT_DATA_.LEFT_X + _G_INIT_DATA_.SECTION_WIDTH, x = _G_INIT_DATA_.LEFT_X + _G_INIT_DATA_.SECTION_WIDTH,
y = header.bottom_y, y = header.bottom_y + _TEXT_SPACING_,
spacing = _TEXT_SPACING_, spacing = _TEXT_SPACING_,
x_align = 'right', x_align = 'right',
text_color = _G_Patterns_.BLUE, text_color = _G_Patterns_.BLUE,
Util.conky('$kernel'), '<row1>',
'<row2>', '<row2>',
'<row3>', '<row3>'
'<row4>'
} }
_TEXT_SPACING_ = nil _TEXT_SPACING_ = nil
local draw_static = function(cr) local draw_static = function(cr)
Text.draw(header.text, cr) Text.draw(header.text, cr)
Text.draw(kernel, cr)
Line.draw(header.underline, cr) Line.draw(header.underline, cr)
TextColumn.draw(labels, cr) TextColumn.draw(labels, cr)
end end
local draw_dynamic = function(cr, pacman_stats) local draw_dynamic = function(cr, pacman_stats)
TextColumn.set(info, cr, 2, Util.conky('$uptime')) TextColumn.set(info, cr, 1, Util.conky('$uptime'))
if pacman_stats then if pacman_stats then
local last_update, last_sync = __string_match(pacman_stats, "^%d+%s+([^%s]+)%s+([^%s]+).*") local last_update, last_sync = __string_match(pacman_stats, "^%d+%s+([^%s]+)%s+([^%s]+).*")
TextColumn.set(info, cr, 3, last_update) TextColumn.set(info, cr, 2, last_update)
TextColumn.set(info, cr, 4, last_sync) TextColumn.set(info, cr, 3, last_sync)
end end
TextColumn.draw(info, cr) TextColumn.draw(info, cr)