2018-08-05 11:22:07 -04:00
|
|
|
local M = {}
|
|
|
|
|
2017-07-19 00:36:15 -04:00
|
|
|
local Text = require 'Text'
|
|
|
|
local Line = require 'Line'
|
|
|
|
local TextColumn = require 'TextColumn'
|
2017-07-19 00:43:44 -04:00
|
|
|
local Util = require 'Util'
|
2017-07-19 00:36:15 -04:00
|
|
|
|
|
|
|
local __string_match = string.match
|
|
|
|
|
|
|
|
local _TEXT_SPACING_ = 20
|
|
|
|
|
|
|
|
local extract_date = function(cmd)
|
2017-07-19 00:43:44 -04:00
|
|
|
local yyyy, mm_dd = __string_match(Util.execute_cmd(cmd), '%[(%d-)%-(%d-%-%d-)%s')
|
2017-07-19 00:36:15 -04:00
|
|
|
return mm_dd..'-'..yyyy
|
|
|
|
end
|
|
|
|
|
2017-07-20 00:49:24 -04:00
|
|
|
local header = _G_Widget_.Header{
|
2017-07-19 00:36:15 -04:00
|
|
|
x = _G_INIT_DATA_.LEFT_X,
|
|
|
|
y = _G_INIT_DATA_.TOP_Y,
|
|
|
|
width = _G_INIT_DATA_.SECTION_WIDTH,
|
|
|
|
header = 'SYSTEM'
|
|
|
|
}
|
|
|
|
|
2017-07-20 00:49:24 -04:00
|
|
|
local labels = _G_Widget_.TextColumn{
|
2017-07-19 00:36:15 -04:00
|
|
|
x = _G_INIT_DATA_.LEFT_X,
|
|
|
|
y = header.bottom_y,
|
|
|
|
spacing = _TEXT_SPACING_,
|
|
|
|
'Kernel',
|
|
|
|
'Uptime',
|
|
|
|
'Last Upgrade',
|
|
|
|
'Last Sync'
|
|
|
|
}
|
2017-07-20 00:49:24 -04:00
|
|
|
local info = _G_Widget_.TextColumn{
|
2017-07-19 00:36:15 -04:00
|
|
|
x = _G_INIT_DATA_.LEFT_X + _G_INIT_DATA_.SECTION_WIDTH,
|
|
|
|
y = header.bottom_y,
|
|
|
|
spacing = _TEXT_SPACING_,
|
|
|
|
x_align = 'right',
|
2017-07-20 00:49:24 -04:00
|
|
|
text_color = _G_Patterns_.BLUE,
|
2017-07-19 00:43:44 -04:00
|
|
|
Util.conky('$kernel'),
|
2017-07-19 00:36:15 -04:00
|
|
|
'<row2>',
|
|
|
|
'<row3>',
|
|
|
|
'<row4>'
|
|
|
|
}
|
|
|
|
|
|
|
|
_TEXT_SPACING_ = nil
|
|
|
|
|
2018-08-05 11:22:07 -04:00
|
|
|
local draw_static = function(cr)
|
2018-08-05 11:35:00 -04:00
|
|
|
Text.draw(header.text, cr)
|
|
|
|
Line.draw(header.underline, cr)
|
|
|
|
TextColumn.draw(labels, cr)
|
2018-08-05 11:22:07 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
local draw_dynamic = function(cr, log_is_changed)
|
2018-08-05 11:08:37 -04:00
|
|
|
TextColumn.set(info, cr, 2, Util.conky('$uptime'))
|
|
|
|
|
|
|
|
if log_is_changed then
|
|
|
|
TextColumn.set(info, cr, 3, extract_date("sed -n "..
|
|
|
|
"'/ starting full system upgrade/p' /var/log/pacman.log | tail -1"))
|
|
|
|
TextColumn.set(info, cr, 4, extract_date("sed -n "..
|
|
|
|
"'/ synchronizing package lists/p' /var/log/pacman.log | tail -1"))
|
|
|
|
end
|
|
|
|
|
|
|
|
TextColumn.draw(info, cr)
|
2017-07-19 00:36:15 -04:00
|
|
|
end
|
|
|
|
|
2018-08-05 11:22:07 -04:00
|
|
|
M.draw_static = draw_static
|
|
|
|
M.draw_dynamic = draw_dynamic
|
|
|
|
|
|
|
|
return M
|