clean up filesystems

This commit is contained in:
petrucci4prez 2017-07-16 15:03:06 -04:00
parent 72998b1890
commit 30f53ce37e
1 changed files with 19 additions and 32 deletions

View File

@ -1,37 +1,31 @@
local _CR = require 'CR'
local Widget = require 'Widget' local Widget = require 'Widget'
local Text = require 'Text' local Text = require 'Text'
local CriticalText = require 'CriticalText'
local Line = require 'Line' local Line = require 'Line'
local TextColumn = require 'TextColumn' local TextColumn = require 'TextColumn'
local CompoundBar = require 'CompoundBar' local CompoundBar = require 'CompoundBar'
local util = require 'util' local util = require 'util'
local schema = require 'default_patterns' local schema = require 'default_patterns'
local _PAIRS = pairs local __string_match = string.match
local _STRING_MATCH = string.match
local FS_PATHS = {'/', '/boot', '/var', '/home', '/mnt/data', '/usr/local/opt'} local _FS_PATHS_ = {'/', '/boot', '/var', '/home', '/mnt/data', '/usr/local/opt'}
local FS_NUM = #FS_PATHS local _MODULE_Y_ = 165
local FS_REGEX = '^([%d%p]-)(%a+)' local _SPACING_ = 20
local _BAR_PAD_ = 100
local MODULE_Y = 165 local FS_NUM = #_FS_PATHS_
local SPACING = 20
local BAR_PAD = 100
local header = Widget.Header{ local header = Widget.Header{
x = _G_INIT_DATA_.RIGHT_X, x = _G_INIT_DATA_.RIGHT_X,
y = MODULE_Y, y = _MODULE_Y_,
width = _G_INIT_DATA_.SECTION_WIDTH, width = _G_INIT_DATA_.SECTION_WIDTH,
header = 'FILE SYSTEMS' header = 'FILE SYSTEMS'
} }
local HEADER_BOTTOM_Y = header.bottom_y
local labels = Widget.TextColumn{ local labels = Widget.TextColumn{
x = _G_INIT_DATA_.RIGHT_X, x = _G_INIT_DATA_.RIGHT_X,
y = HEADER_BOTTOM_Y, y = header.bottom_y,
spacing = SPACING, spacing = _SPACING_,
'root', 'root',
'boot', 'boot',
'var', 'var',
@ -42,42 +36,35 @@ local labels = Widget.TextColumn{
local conky_used_perc = {} local conky_used_perc = {}
for i, v in _PAIRS(FS_PATHS) do for i, v in pairs(_FS_PATHS_) do
conky_used_perc[i] = '${fs_used_perc '..v..'}' conky_used_perc[i] = '${fs_used_perc '..v..'}'
end end
local bars = Widget.CompoundBar{ local bars = Widget.CompoundBar{
x = _G_INIT_DATA_.RIGHT_X + BAR_PAD, x = _G_INIT_DATA_.RIGHT_X + _BAR_PAD_,
y = HEADER_BOTTOM_Y, y = header.bottom_y,
length = _G_INIT_DATA_.SECTION_WIDTH - BAR_PAD, length = _G_INIT_DATA_.SECTION_WIDTH - _BAR_PAD_,
spacing = SPACING, spacing = _SPACING_,
num_bars = FS_NUM, num_bars = FS_NUM,
critical_limit = '>0.8' critical_limit = '>0.8'
} }
Widget = nil Widget = nil
_PAIRS = nil
schema = nil schema = nil
SPACING = nil _SPACING_ = nil
TEXT_WIDTH = nil _BAR_PAD_ = nil
BAR_PAD = nil _FS_PATHS_ = nil
FS_PATHS = nil
HEADER_BOTTOM_Y = nil
local __update = function(cr) local update = function(cr)
for i = 1, FS_NUM do for i = 1, FS_NUM do
local percent = util.conky_numeric(conky_used_perc[i]) local percent = util.conky_numeric(conky_used_perc[i])
CompoundBar.set(bars, i, percent * 0.01) CompoundBar.set(bars, i, percent * 0.01)
end end
end end
__update(_CR)
_CR = nil
local draw = function(cr, current_interface, trigger) local draw = function(cr, current_interface, trigger)
if trigger == 0 then __update(cr) end if trigger == 0 then update(cr) end
if current_interface == 0 then if current_interface == 0 then
Text.draw(header.text, cr) Text.draw(header.text, cr)