ENH parameterize filesystem (actually)
This commit is contained in:
parent
779452e9d1
commit
c5df3172a6
|
@ -1,4 +1,3 @@
|
||||||
local line = require 'line'
|
|
||||||
local i_o = require 'i_o'
|
local i_o = require 'i_o'
|
||||||
local common = require 'common'
|
local common = require 'common'
|
||||||
local geometry = require 'geometry'
|
local geometry = require 'geometry'
|
||||||
|
@ -11,83 +10,97 @@ return function(pathspecs)
|
||||||
local BAR_PAD = 100
|
local BAR_PAD = 100
|
||||||
local SEPARATOR_SPACING = 20
|
local SEPARATOR_SPACING = 20
|
||||||
|
|
||||||
local paths, names = table.unpack(pure.unzip(pathspecs))
|
|
||||||
|
|
||||||
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
-- header
|
-- header
|
||||||
|
|
||||||
local header = common.make_header(
|
local mk_header = pure.partial(
|
||||||
geometry.RIGHT_X,
|
common.mk_header,
|
||||||
MODULE_Y,
|
'FILE SYSTEMS',
|
||||||
geometry.SECTION_WIDTH,
|
geometry.SECTION_WIDTH,
|
||||||
'FILE SYSTEMS'
|
geometry.RIGHT_X
|
||||||
)
|
)
|
||||||
|
|
||||||
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
-- smartd
|
-- smartd
|
||||||
|
|
||||||
local smart = common.make_text_row(
|
local mk_smart = function(y)
|
||||||
geometry.RIGHT_X,
|
local obj = common.make_text_row(
|
||||||
header.bottom_y,
|
geometry.RIGHT_X,
|
||||||
|
y,
|
||||||
|
geometry.SECTION_WIDTH,
|
||||||
|
'SMART Daemon'
|
||||||
|
)
|
||||||
|
local update = function(trigger)
|
||||||
|
if trigger == 0 then
|
||||||
|
local pid = i_o.execute_cmd('pidof smartd', nil, '*n')
|
||||||
|
common.text_row_set(obj, (pid == '') and 'Error' or 'Running')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return common.mk_acc(
|
||||||
|
0,
|
||||||
|
update,
|
||||||
|
pure.partial(common.text_row_draw_static, obj),
|
||||||
|
pure.partial(common.text_row_draw_dynamic, obj)
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
local mk_sep = pure.partial(
|
||||||
|
common.mk_seperator,
|
||||||
geometry.SECTION_WIDTH,
|
geometry.SECTION_WIDTH,
|
||||||
'SMART Daemon'
|
geometry.RIGHT_X
|
||||||
)
|
|
||||||
|
|
||||||
local SEP_Y = header.bottom_y + SEPARATOR_SPACING
|
|
||||||
|
|
||||||
local separator = common.make_separator(
|
|
||||||
geometry.RIGHT_X,
|
|
||||||
SEP_Y,
|
|
||||||
geometry.SECTION_WIDTH
|
|
||||||
)
|
)
|
||||||
|
|
||||||
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
-- filesystem bar chart
|
-- filesystem bar chart
|
||||||
|
|
||||||
local BAR_Y = SEP_Y + SEPARATOR_SPACING
|
local mk_bars = function(y)
|
||||||
|
local paths, names = table.unpack(pure.unzip(pathspecs))
|
||||||
local fs = common.make_compound_bar(
|
local CONKY_CMDS = pure.map(
|
||||||
geometry.RIGHT_X,
|
pure.partial(string.format, '${fs_used_perc %s}', true),
|
||||||
BAR_Y,
|
paths
|
||||||
geometry.SECTION_WIDTH,
|
)
|
||||||
BAR_PAD,
|
local obj = common.make_compound_bar(
|
||||||
names,
|
geometry.RIGHT_X,
|
||||||
SPACING,
|
y,
|
||||||
12,
|
geometry.SECTION_WIDTH,
|
||||||
80
|
BAR_PAD,
|
||||||
)
|
names,
|
||||||
|
SPACING,
|
||||||
local CONKY_CMDS = pure.map(
|
12,
|
||||||
pure.partial(string.format, '${fs_used_perc %s}', true),
|
80
|
||||||
paths
|
)
|
||||||
)
|
local read_fs = function(index, cmd)
|
||||||
|
common.compound_bar_set(obj, index, i_o.conky_numeric(cmd))
|
||||||
local read_fs = function(index, cmd)
|
end
|
||||||
common.compound_bar_set(fs, index, i_o.conky_numeric(cmd))
|
local update = function(trigger)
|
||||||
|
if trigger == 0 then
|
||||||
|
impure.ieach(read_fs, CONKY_CMDS)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return common.mk_acc(
|
||||||
|
(#pathspecs - 1) * SPACING,
|
||||||
|
update,
|
||||||
|
pure.partial(common.compound_bar_draw_static, obj),
|
||||||
|
pure.partial(common.compound_bar_draw_dynamic, obj)
|
||||||
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
-- main functions
|
-- main functions
|
||||||
|
|
||||||
local update = function(trigger)
|
local rbs = common.reduce_blocks_(
|
||||||
if trigger == 0 then
|
MODULE_Y,
|
||||||
local smart_pid = i_o.execute_cmd('pidof smartd', nil, '*n')
|
{
|
||||||
common.text_row_set(smart, (smart_pid == '') and 'Error' or 'Running')
|
common.mk_block(mk_header, true, 0),
|
||||||
impure.ieach(read_fs, CONKY_CMDS)
|
common.mk_block(mk_smart, true, 0),
|
||||||
end
|
common.mk_block(mk_sep, true, SEPARATOR_SPACING),
|
||||||
end
|
common.mk_block(mk_bars, true, SEPARATOR_SPACING),
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
local draw_static = function(cr)
|
return {
|
||||||
common.draw_header(cr, header)
|
static = rbs.static_drawer,
|
||||||
common.text_row_draw_static(smart, cr)
|
dynamic = rbs.dynamic_drawer,
|
||||||
line.draw(separator, cr)
|
update = rbs.updater
|
||||||
common.compound_bar_draw_static(fs, cr)
|
}
|
||||||
end
|
|
||||||
|
|
||||||
local draw_dynamic = function(cr)
|
|
||||||
common.text_row_draw_dynamic(smart, cr)
|
|
||||||
common.compound_bar_draw_dynamic(fs, cr)
|
|
||||||
end
|
|
||||||
|
|
||||||
return {static = draw_static, dynamic = draw_dynamic, update = update}
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
local compound_dial = require 'compound_dial'
|
local compound_dial = require 'compound_dial'
|
||||||
local line = require 'line'
|
|
||||||
local text_table = require 'text_table'
|
local text_table = require 'text_table'
|
||||||
local i_o = require 'i_o'
|
local i_o = require 'i_o'
|
||||||
local common = require 'common'
|
local common = require 'common'
|
||||||
|
|
Loading…
Reference in New Issue