2021-08-08 15:58:53 -04:00
|
|
|
local i_o = require 'i_o'
|
2021-08-08 19:12:31 -04:00
|
|
|
local pure = require 'pure'
|
|
|
|
local impure = require 'impure'
|
2017-07-19 00:36:15 -04:00
|
|
|
|
2022-07-17 18:40:24 -04:00
|
|
|
return function(config, main_state, common, width, point)
|
2021-07-17 23:12:59 -04:00
|
|
|
local SPACING = 20
|
|
|
|
local BAR_PAD = 100
|
|
|
|
local SEPARATOR_SPACING = 20
|
|
|
|
|
|
|
|
-----------------------------------------------------------------------------
|
|
|
|
-- smartd
|
|
|
|
|
2022-07-19 23:04:43 -04:00
|
|
|
i_o.exe_assert('pidof')
|
|
|
|
|
2022-07-14 18:20:08 -04:00
|
|
|
local mk_smart = function(y)
|
2022-07-17 12:40:36 -04:00
|
|
|
local obj = common.make_text_row(point.x, y, width, 'SMART Daemon')
|
2022-07-16 00:27:27 -04:00
|
|
|
local update = function()
|
|
|
|
if main_state.trigger10 == 0 then
|
2022-07-14 18:20:08 -04:00
|
|
|
local pid = i_o.execute_cmd('pidof smartd', nil, '*n')
|
|
|
|
common.text_row_set(obj, (pid == '') and 'Error' or 'Running')
|
|
|
|
end
|
|
|
|
end
|
2022-07-17 18:54:23 -04:00
|
|
|
return common.mk_acc(
|
2022-07-17 12:40:36 -04:00
|
|
|
width,
|
2022-07-14 18:20:08 -04:00
|
|
|
0,
|
|
|
|
update,
|
|
|
|
pure.partial(common.text_row_draw_static, obj),
|
|
|
|
pure.partial(common.text_row_draw_dynamic, obj)
|
|
|
|
)
|
|
|
|
end
|
2021-07-17 23:12:59 -04:00
|
|
|
|
|
|
|
-----------------------------------------------------------------------------
|
|
|
|
-- filesystem bar chart
|
|
|
|
|
2022-07-14 18:20:08 -04:00
|
|
|
local mk_bars = function(y)
|
2022-07-17 01:25:53 -04:00
|
|
|
local paths = pure.map_keys('path', config.fs_paths)
|
|
|
|
local names = pure.map_keys('name', config.fs_paths)
|
2022-07-14 18:20:08 -04:00
|
|
|
local CONKY_CMDS = pure.map(
|
|
|
|
pure.partial(string.format, '${fs_used_perc %s}', true),
|
|
|
|
paths
|
|
|
|
)
|
|
|
|
local obj = common.make_compound_bar(
|
2022-07-14 20:13:29 -04:00
|
|
|
point.x,
|
2022-07-14 18:20:08 -04:00
|
|
|
y,
|
2022-07-17 12:40:36 -04:00
|
|
|
width,
|
2022-07-14 18:20:08 -04:00
|
|
|
BAR_PAD,
|
|
|
|
names,
|
|
|
|
SPACING,
|
|
|
|
12,
|
|
|
|
80
|
|
|
|
)
|
|
|
|
local read_fs = function(index, cmd)
|
|
|
|
common.compound_bar_set(obj, index, i_o.conky_numeric(cmd))
|
|
|
|
end
|
2022-07-16 00:27:27 -04:00
|
|
|
local update = function()
|
|
|
|
if main_state.trigger10 == 0 then
|
2022-07-14 18:20:08 -04:00
|
|
|
impure.ieach(read_fs, CONKY_CMDS)
|
|
|
|
end
|
|
|
|
end
|
2022-07-17 18:54:23 -04:00
|
|
|
return common.mk_acc(
|
2022-07-17 12:40:36 -04:00
|
|
|
width,
|
2022-07-16 23:48:01 -04:00
|
|
|
(#config.fs_paths - 1) * SPACING,
|
2022-07-14 18:20:08 -04:00
|
|
|
update,
|
|
|
|
pure.partial(common.compound_bar_draw_static, obj),
|
|
|
|
pure.partial(common.compound_bar_draw_dynamic, obj)
|
|
|
|
)
|
2021-07-17 23:12:59 -04:00
|
|
|
end
|
2017-07-19 00:36:15 -04:00
|
|
|
|
2021-07-17 23:12:59 -04:00
|
|
|
-----------------------------------------------------------------------------
|
|
|
|
-- main functions
|
2017-07-19 00:36:15 -04:00
|
|
|
|
2022-07-17 19:12:31 -04:00
|
|
|
return {
|
|
|
|
header = 'FILE SYSTEMS',
|
|
|
|
point = point,
|
|
|
|
width = width,
|
2022-07-17 22:30:38 -04:00
|
|
|
set_state = nil,
|
2022-07-17 19:12:31 -04:00
|
|
|
top = {{mk_smart, config.show_smart, SEPARATOR_SPACING}},
|
2022-07-17 19:18:52 -04:00
|
|
|
common.mk_section(SEPARATOR_SPACING, {mk_bars, true, 0})
|
2022-07-17 19:12:31 -04:00
|
|
|
}
|
2021-07-17 00:17:22 -04:00
|
|
|
end
|