From 30f53ce37ea8e95c6223de15c6edd269e24530d8 Mon Sep 17 00:00:00 2001 From: petrucci4prez Date: Sun, 16 Jul 2017 15:03:06 -0400 Subject: [PATCH] clean up filesystems --- module/FileSystem.lua | 51 ++++++++++++++++--------------------------- 1 file changed, 19 insertions(+), 32 deletions(-) diff --git a/module/FileSystem.lua b/module/FileSystem.lua index 2c549d1..850a69e 100644 --- a/module/FileSystem.lua +++ b/module/FileSystem.lua @@ -1,37 +1,31 @@ -local _CR = require 'CR' local Widget = require 'Widget' local Text = require 'Text' -local CriticalText = require 'CriticalText' local Line = require 'Line' local TextColumn = require 'TextColumn' local CompoundBar = require 'CompoundBar' local util = require 'util' 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_NUM = #FS_PATHS -local FS_REGEX = '^([%d%p]-)(%a+)' +local _FS_PATHS_ = {'/', '/boot', '/var', '/home', '/mnt/data', '/usr/local/opt'} +local _MODULE_Y_ = 165 +local _SPACING_ = 20 +local _BAR_PAD_ = 100 -local MODULE_Y = 165 -local SPACING = 20 -local BAR_PAD = 100 +local FS_NUM = #_FS_PATHS_ local header = Widget.Header{ x = _G_INIT_DATA_.RIGHT_X, - y = MODULE_Y, + y = _MODULE_Y_, width = _G_INIT_DATA_.SECTION_WIDTH, header = 'FILE SYSTEMS' } -local HEADER_BOTTOM_Y = header.bottom_y - local labels = Widget.TextColumn{ x = _G_INIT_DATA_.RIGHT_X, - y = HEADER_BOTTOM_Y, - spacing = SPACING, + y = header.bottom_y, + spacing = _SPACING_, 'root', 'boot', 'var', @@ -42,42 +36,35 @@ local labels = Widget.TextColumn{ 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..'}' end local bars = Widget.CompoundBar{ - x = _G_INIT_DATA_.RIGHT_X + BAR_PAD, - y = HEADER_BOTTOM_Y, - length = _G_INIT_DATA_.SECTION_WIDTH - BAR_PAD, - spacing = SPACING, + x = _G_INIT_DATA_.RIGHT_X + _BAR_PAD_, + y = header.bottom_y, + length = _G_INIT_DATA_.SECTION_WIDTH - _BAR_PAD_, + spacing = _SPACING_, num_bars = FS_NUM, critical_limit = '>0.8' } Widget = nil -_PAIRS = nil schema = nil -SPACING = nil -TEXT_WIDTH = nil -BAR_PAD = nil -FS_PATHS = nil -HEADER_BOTTOM_Y = nil +_SPACING_ = nil +_BAR_PAD_ = nil +_FS_PATHS_ = nil -local __update = function(cr) +local update = function(cr) for i = 1, FS_NUM do local percent = util.conky_numeric(conky_used_perc[i]) CompoundBar.set(bars, i, percent * 0.01) end end -__update(_CR) - -_CR = nil - 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 Text.draw(header.text, cr)