REF make pacman and system modules look pretty
This commit is contained in:
parent
81b6a6b2aa
commit
862967089f
|
@ -1,53 +1,51 @@
|
||||||
local Common = require 'Common'
|
local Common = require 'Common'
|
||||||
local Geometry = require 'Geometry'
|
local Geometry = require 'Geometry'
|
||||||
|
|
||||||
local __string_match = string.match
|
return function()
|
||||||
local __string_gmatch = string.gmatch
|
local TEXT_SPACING = 20
|
||||||
|
|
||||||
local _TEXT_SPACING_ = 20
|
local __string_match = string.match
|
||||||
|
local __string_gmatch = string.gmatch
|
||||||
|
|
||||||
local header = Common.Header(
|
local header = Common.Header(
|
||||||
Geometry.RIGHT_X,
|
Geometry.RIGHT_X,
|
||||||
Geometry.TOP_Y,
|
Geometry.TOP_Y,
|
||||||
Geometry.SECTION_WIDTH,
|
Geometry.SECTION_WIDTH,
|
||||||
'PACMAN'
|
'PACMAN'
|
||||||
)
|
)
|
||||||
|
|
||||||
local rows = Common.initTextRows(
|
local rows = Common.initTextRows(
|
||||||
Geometry.RIGHT_X,
|
Geometry.RIGHT_X,
|
||||||
header.bottom_y,
|
header.bottom_y,
|
||||||
Geometry.SECTION_WIDTH,
|
Geometry.SECTION_WIDTH,
|
||||||
_TEXT_SPACING_,
|
TEXT_SPACING,
|
||||||
{'Total', 'Explicit', 'Outdated', 'Orphaned', 'Local'}
|
{'Total', 'Explicit', 'Outdated', 'Orphaned', 'Local'}
|
||||||
)
|
)
|
||||||
|
|
||||||
_TEXT_SPACING_ = nil
|
local update = function(cr, pacman_stats)
|
||||||
|
local stats = __string_match(pacman_stats, '%d+%s+[^%s]+%s+[^%s]+%s+(.*)$')
|
||||||
local update = function(cr, pacman_stats)
|
if stats then
|
||||||
local stats = __string_match(pacman_stats, '%d+%s+[^%s]+%s+[^%s]+%s+(.*)$')
|
local i = 1
|
||||||
if stats then
|
for v in __string_gmatch(stats, '%d+') do
|
||||||
local i = 1
|
Common.text_rows_set(rows, cr, i, v)
|
||||||
for v in __string_gmatch(stats, '%d+') do
|
i = i + 1
|
||||||
Common.text_rows_set(rows, cr, i, v)
|
end
|
||||||
i = i + 1
|
else
|
||||||
end
|
for i=1, 5 do
|
||||||
else
|
Common.text_rows_set(rows, cr, i, 'N/A')
|
||||||
for i=1, 5 do
|
end
|
||||||
Common.text_rows_set(rows, cr, i, 'N/A')
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
local draw_static = function(cr)
|
local draw_static = function(cr)
|
||||||
Common.drawHeader(cr, header)
|
Common.drawHeader(cr, header)
|
||||||
Common.text_rows_draw_static(rows, cr)
|
Common.text_rows_draw_static(rows, cr)
|
||||||
end
|
end
|
||||||
|
|
||||||
local draw_dynamic = function(cr, pacman_stats)
|
local draw_dynamic = function(cr, pacman_stats)
|
||||||
update(cr, pacman_stats)
|
update(cr, pacman_stats)
|
||||||
Common.text_rows_draw_dynamic(rows, cr)
|
Common.text_rows_draw_dynamic(rows, cr)
|
||||||
end
|
end
|
||||||
|
|
||||||
return function()
|
|
||||||
return {static = draw_static, dynamic = draw_dynamic}
|
return {static = draw_static, dynamic = draw_dynamic}
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,44 +2,43 @@ local Util = require 'Util'
|
||||||
local Common = require 'Common'
|
local Common = require 'Common'
|
||||||
local Geometry = require 'Geometry'
|
local Geometry = require 'Geometry'
|
||||||
|
|
||||||
local __string_match = string.match
|
|
||||||
|
|
||||||
local _TEXT_SPACING_ = 20
|
|
||||||
|
|
||||||
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'}
|
|
||||||
)
|
|
||||||
|
|
||||||
_TEXT_SPACING_ = nil
|
|
||||||
|
|
||||||
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
|
|
||||||
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)
|
|
||||||
end
|
|
||||||
|
|
||||||
return function()
|
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
|
||||||
|
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)
|
||||||
|
end
|
||||||
|
|
||||||
return {static = draw_static, dynamic = draw_dynamic}
|
return {static = draw_static, dynamic = draw_dynamic}
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue