2021-07-29 22:37:30 -04:00
|
|
|
local line = require 'line'
|
2021-08-08 15:58:53 -04:00
|
|
|
local i_o = require 'i_o'
|
2021-07-29 22:18:29 -04:00
|
|
|
local common = require 'common'
|
|
|
|
local geometry = require 'geometry'
|
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-13 01:17:58 -04:00
|
|
|
return function(pathspecs)
|
2021-07-17 23:12:59 -04:00
|
|
|
local MODULE_Y = 170
|
|
|
|
local SPACING = 20
|
|
|
|
local BAR_PAD = 100
|
|
|
|
local SEPARATOR_SPACING = 20
|
|
|
|
|
2022-07-13 01:17:58 -04:00
|
|
|
local paths, names = table.unpack(pure.unzip(pathspecs))
|
|
|
|
|
2021-07-17 23:12:59 -04:00
|
|
|
-----------------------------------------------------------------------------
|
|
|
|
-- header
|
|
|
|
|
2021-07-29 23:04:39 -04:00
|
|
|
local header = common.make_header(
|
2021-07-29 22:18:29 -04:00
|
|
|
geometry.RIGHT_X,
|
2021-07-17 23:12:59 -04:00
|
|
|
MODULE_Y,
|
2021-07-29 22:18:29 -04:00
|
|
|
geometry.SECTION_WIDTH,
|
2021-07-17 23:12:59 -04:00
|
|
|
'FILE SYSTEMS'
|
|
|
|
)
|
|
|
|
|
|
|
|
-----------------------------------------------------------------------------
|
|
|
|
-- smartd
|
|
|
|
|
2021-07-29 23:04:39 -04:00
|
|
|
local smart = common.make_text_row(
|
2021-07-29 22:18:29 -04:00
|
|
|
geometry.RIGHT_X,
|
2021-07-17 23:12:59 -04:00
|
|
|
header.bottom_y,
|
2021-07-29 22:18:29 -04:00
|
|
|
geometry.SECTION_WIDTH,
|
2021-07-17 23:12:59 -04:00
|
|
|
'SMART Daemon'
|
|
|
|
)
|
|
|
|
|
|
|
|
local SEP_Y = header.bottom_y + SEPARATOR_SPACING
|
|
|
|
|
2021-07-29 23:04:39 -04:00
|
|
|
local separator = common.make_separator(
|
2021-07-29 22:18:29 -04:00
|
|
|
geometry.RIGHT_X,
|
2021-07-17 23:12:59 -04:00
|
|
|
SEP_Y,
|
2021-07-29 22:18:29 -04:00
|
|
|
geometry.SECTION_WIDTH
|
2021-07-17 23:12:59 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
-----------------------------------------------------------------------------
|
|
|
|
-- filesystem bar chart
|
|
|
|
|
|
|
|
local BAR_Y = SEP_Y + SEPARATOR_SPACING
|
|
|
|
|
2021-07-30 22:02:46 -04:00
|
|
|
local fs = common.make_compound_bar(
|
2021-07-29 22:18:29 -04:00
|
|
|
geometry.RIGHT_X,
|
2021-07-17 23:12:59 -04:00
|
|
|
BAR_Y,
|
2021-07-29 22:18:29 -04:00
|
|
|
geometry.SECTION_WIDTH,
|
2021-07-17 23:12:59 -04:00
|
|
|
BAR_PAD,
|
2022-07-13 01:17:58 -04:00
|
|
|
names,
|
2021-07-17 23:12:59 -04:00
|
|
|
SPACING,
|
|
|
|
12,
|
2021-11-10 12:32:29 -05:00
|
|
|
80
|
2021-07-17 23:12:59 -04:00
|
|
|
)
|
|
|
|
|
2021-08-08 19:12:31 -04:00
|
|
|
local CONKY_CMDS = pure.map(
|
|
|
|
pure.partial(string.format, '${fs_used_perc %s}', true),
|
|
|
|
paths
|
|
|
|
)
|
|
|
|
|
|
|
|
local read_fs = function(index, cmd)
|
2021-11-10 12:32:29 -05:00
|
|
|
common.compound_bar_set(fs, index, i_o.conky_numeric(cmd))
|
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
|
|
|
|
2021-07-27 23:47:26 -04:00
|
|
|
local update = function(trigger)
|
|
|
|
if trigger == 0 then
|
2021-08-08 15:58:53 -04:00
|
|
|
local smart_pid = i_o.execute_cmd('pidof smartd', nil, '*n')
|
2021-07-29 22:18:29 -04:00
|
|
|
common.text_row_set(smart, (smart_pid == '') and 'Error' or 'Running')
|
2021-08-08 19:12:31 -04:00
|
|
|
impure.ieach(read_fs, CONKY_CMDS)
|
2021-07-17 23:12:59 -04:00
|
|
|
end
|
2021-02-02 18:21:32 -05:00
|
|
|
end
|
2017-07-19 00:36:15 -04:00
|
|
|
|
2021-07-17 23:12:59 -04:00
|
|
|
local draw_static = function(cr)
|
2021-07-29 23:04:39 -04:00
|
|
|
common.draw_header(cr, header)
|
2021-07-29 22:18:29 -04:00
|
|
|
common.text_row_draw_static(smart, cr)
|
2021-07-29 22:37:30 -04:00
|
|
|
line.draw(separator, cr)
|
2021-07-29 22:18:29 -04:00
|
|
|
common.compound_bar_draw_static(fs, cr)
|
2021-07-17 23:12:59 -04:00
|
|
|
end
|
2018-08-05 11:22:07 -04:00
|
|
|
|
2021-07-27 23:47:26 -04:00
|
|
|
local draw_dynamic = function(cr)
|
2021-07-29 22:18:29 -04:00
|
|
|
common.text_row_draw_dynamic(smart, cr)
|
|
|
|
common.compound_bar_draw_dynamic(fs, cr)
|
2021-07-17 23:12:59 -04:00
|
|
|
end
|
2017-07-19 00:36:15 -04:00
|
|
|
|
2021-07-27 23:47:26 -04:00
|
|
|
return {static = draw_static, dynamic = draw_dynamic, update = update}
|
2021-07-17 00:17:22 -04:00
|
|
|
end
|