2018-08-05 11:22:07 -04:00
|
|
|
local M = {}
|
|
|
|
|
2021-02-02 18:21:32 -05:00
|
|
|
local Patterns = require 'Patterns'
|
2017-07-19 00:36:15 -04:00
|
|
|
local Line = require 'Line'
|
|
|
|
local TextColumn = require 'TextColumn'
|
|
|
|
local CompoundBar = require 'CompoundBar'
|
2017-07-19 00:43:44 -04:00
|
|
|
local Util = require 'Util'
|
2021-07-05 23:27:43 -04:00
|
|
|
local Common = require 'Common'
|
2017-07-19 00:36:15 -04:00
|
|
|
|
2021-05-12 12:54:58 -04:00
|
|
|
local _FS_PATHS_ = {'/', '/boot', '/home', '/mnt/data', '/mnt/dcache', "/tmp"}
|
2018-08-05 18:04:22 -04:00
|
|
|
local _MODULE_Y_ = 170
|
2021-02-01 03:02:52 -05:00
|
|
|
local _SPACING_ = 20
|
2017-07-19 00:36:15 -04:00
|
|
|
local _BAR_PAD_ = 100
|
2021-02-02 18:21:32 -05:00
|
|
|
local _SEPARATOR_SPACING_ = 20
|
2017-07-19 00:36:15 -04:00
|
|
|
|
|
|
|
local FS_NUM = #_FS_PATHS_
|
|
|
|
|
2021-07-05 23:27:43 -04:00
|
|
|
local header = Common.Header(
|
|
|
|
_G_INIT_DATA_.RIGHT_X,
|
|
|
|
_MODULE_Y_,
|
|
|
|
_G_INIT_DATA_.SECTION_WIDTH,
|
|
|
|
'FILE SYSTEMS'
|
|
|
|
)
|
2017-07-19 00:36:15 -04:00
|
|
|
|
|
|
|
local conky_used_perc = {}
|
|
|
|
|
|
|
|
for i, v in pairs(_FS_PATHS_) do
|
|
|
|
conky_used_perc[i] = '${fs_used_perc '..v..'}'
|
|
|
|
end
|
|
|
|
|
2021-07-05 23:27:43 -04:00
|
|
|
local smart = Common.initTextRow(
|
|
|
|
_G_INIT_DATA_.RIGHT_X,
|
|
|
|
header.bottom_y,
|
|
|
|
_G_INIT_DATA_.SECTION_WIDTH,
|
|
|
|
'SMART Daemon'
|
|
|
|
)
|
2021-02-02 18:21:32 -05:00
|
|
|
|
|
|
|
local _SEP_Y_ = header.bottom_y + _SEPARATOR_SPACING_
|
|
|
|
|
2021-07-05 23:27:43 -04:00
|
|
|
local separator = Common.initSeparator(
|
|
|
|
_G_INIT_DATA_.RIGHT_X,
|
|
|
|
_SEP_Y_,
|
|
|
|
_G_INIT_DATA_.SECTION_WIDTH
|
|
|
|
)
|
2021-02-02 18:21:32 -05:00
|
|
|
|
|
|
|
local _BAR_Y_ = _SEP_Y_ + _SEPARATOR_SPACING_
|
|
|
|
|
2017-07-20 00:49:24 -04:00
|
|
|
local bars = _G_Widget_.CompoundBar{
|
2017-07-19 00:36:15 -04:00
|
|
|
x = _G_INIT_DATA_.RIGHT_X + _BAR_PAD_,
|
2021-02-02 18:21:32 -05:00
|
|
|
y = _BAR_Y_,
|
2017-07-19 00:36:15 -04:00
|
|
|
length = _G_INIT_DATA_.SECTION_WIDTH - _BAR_PAD_,
|
|
|
|
spacing = _SPACING_,
|
|
|
|
num_bars = FS_NUM,
|
2021-02-01 03:02:52 -05:00
|
|
|
-- thickness = 12,
|
2021-07-06 19:32:18 -04:00
|
|
|
critical_limit = 0.8,
|
2021-07-04 22:24:18 -04:00
|
|
|
indicator_pattern = Patterns.INDICATOR_FG_PRIMARY,
|
2021-07-06 18:56:24 -04:00
|
|
|
critical_pattern = Patterns.INDICATOR_FG_CRITICAL,
|
2021-07-04 22:24:18 -04:00
|
|
|
line_pattern = Patterns.INDICATOR_BG,
|
2017-07-19 00:36:15 -04:00
|
|
|
}
|
|
|
|
|
2021-02-02 18:21:32 -05:00
|
|
|
local labels = _G_Widget_.TextColumn{
|
|
|
|
x = _G_INIT_DATA_.RIGHT_X,
|
|
|
|
y = _BAR_Y_,
|
|
|
|
spacing = _SPACING_,
|
2021-07-05 23:27:43 -04:00
|
|
|
text_color = _G_Patterns_.INACTIVE_TEXT_FG,
|
2021-07-06 00:11:00 -04:00
|
|
|
font_spec = Common.normal_font_spec,
|
2021-02-02 18:21:32 -05:00
|
|
|
'root',
|
|
|
|
'boot',
|
|
|
|
'home',
|
|
|
|
'data',
|
|
|
|
'dcache',
|
2021-05-12 12:54:58 -04:00
|
|
|
'tmpfs',
|
2021-02-02 18:21:32 -05:00
|
|
|
}
|
|
|
|
|
2017-07-19 00:36:15 -04:00
|
|
|
_SPACING_ = nil
|
|
|
|
_BAR_PAD_ = nil
|
|
|
|
_FS_PATHS_ = nil
|
2021-02-02 18:21:32 -05:00
|
|
|
_SEPARATOR_SPACING_ = nil
|
|
|
|
_BAR_Y_ = nil
|
|
|
|
_SEPARATOR_SPACING_ = nil
|
|
|
|
_SEP_Y_ = nil
|
2017-07-19 00:36:15 -04:00
|
|
|
|
|
|
|
local update = function(cr)
|
2021-02-02 18:21:32 -05:00
|
|
|
local smart_pid = Util.execute_cmd('pidof smartd', nil, '*n')
|
2021-07-05 23:27:43 -04:00
|
|
|
Common.text_row_set(smart, cr, (smart_pid == '') and 'Error' or 'Running')
|
|
|
|
|
2021-02-02 18:21:32 -05:00
|
|
|
for i = 1, FS_NUM do
|
|
|
|
local percent = Util.conky_numeric(conky_used_perc[i])
|
|
|
|
CompoundBar.set(bars, i, percent * 0.01)
|
|
|
|
end
|
2017-07-19 00:36:15 -04:00
|
|
|
end
|
|
|
|
|
2021-07-06 00:11:00 -04:00
|
|
|
M.draw_static = function(cr)
|
2021-07-05 23:27:43 -04:00
|
|
|
Common.drawHeader(cr, header)
|
2018-08-05 11:22:07 -04:00
|
|
|
|
2021-07-05 23:27:43 -04:00
|
|
|
Common.text_row_draw_static(smart, cr)
|
2021-02-02 18:21:32 -05:00
|
|
|
Line.draw(separator, cr)
|
|
|
|
|
2018-08-05 11:35:00 -04:00
|
|
|
TextColumn.draw(labels, cr)
|
2018-08-05 14:54:49 -04:00
|
|
|
CompoundBar.draw_static(bars, cr)
|
2018-08-05 11:22:07 -04:00
|
|
|
end
|
|
|
|
|
2021-07-06 00:11:00 -04:00
|
|
|
M.draw_dynamic = function(cr, trigger)
|
2018-08-05 11:08:37 -04:00
|
|
|
if trigger == 0 then update(cr) end
|
2017-07-19 00:36:15 -04:00
|
|
|
|
2021-07-05 23:27:43 -04:00
|
|
|
Common.text_row_draw_dynamic(smart, cr)
|
2021-02-02 18:21:32 -05:00
|
|
|
|
2018-08-05 14:54:49 -04:00
|
|
|
CompoundBar.draw_dynamic(bars, cr)
|
2017-07-19 00:36:15 -04:00
|
|
|
end
|
|
|
|
|
2018-08-05 11:22:07 -04:00
|
|
|
return M
|