conky-config/drawing/pacman.lua

51 lines
1.2 KiB
Lua
Raw Normal View History

local pure = require 'pure'
2017-07-19 00:36:15 -04:00
return function(main_state, common, width, point)
local TEXT_SPACING = 20
local __string_match = string.match
local __string_gmatch = string.gmatch
local mk_stats = function(y)
local obj = common.make_text_rows(
point.x,
y,
width,
TEXT_SPACING,
{'Total', 'Explicit', 'Outdated', 'Orphaned', 'Local'}
)
local update = function()
2022-07-16 00:00:06 -04:00
local stats = __string_match(
main_state.pacman_stats,
2022-07-16 00:00:06 -04:00
'%d+%s+[^%s]+%s+[^%s]+%s+(.*)$'
)
if stats then
local i = 1
for v in __string_gmatch(stats, '%d+') do
common.text_rows_set(obj, i, v)
i = i + 1
end
else
for i = 1, 5 do
common.text_rows_set(obj, i, 'N/A')
end
end
end
2022-07-17 18:54:23 -04:00
return common.mk_acc(
width,
TEXT_SPACING * 4,
update,
pure.partial(common.text_rows_draw_static, obj),
pure.partial(common.text_rows_draw_dynamic, obj)
)
end
2017-07-19 00:36:15 -04:00
return {
header = 'PACMAN',
point = point,
width = width,
update_wrapper = nil,
top = {{mk_stats, true, 0}}
}
end