From 5604df2eb686e4c6e002d8e3b035d7474a859295 Mon Sep 17 00:00:00 2001 From: ndwarshuis Date: Wed, 13 Jul 2022 01:17:58 -0400 Subject: [PATCH] ENH use central list for names/paths of filesystems --- drawing/filesystem.lua | 6 ++++-- drawing/readwrite.lua | 1 + main.lua | 9 ++++++++- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/drawing/filesystem.lua b/drawing/filesystem.lua index c643462..b8ef880 100644 --- a/drawing/filesystem.lua +++ b/drawing/filesystem.lua @@ -5,12 +5,14 @@ local geometry = require 'geometry' local pure = require 'pure' local impure = require 'impure' -return function(paths) +return function(pathspecs) local MODULE_Y = 170 local SPACING = 20 local BAR_PAD = 100 local SEPARATOR_SPACING = 20 + local paths, names = table.unpack(pure.unzip(pathspecs)) + ----------------------------------------------------------------------------- -- header @@ -49,7 +51,7 @@ return function(paths) BAR_Y, geometry.SECTION_WIDTH, BAR_PAD, - {'root', 'boot', 'home', 'data', 'dcache', 'tmpfs'}, + names, SPACING, 12, 80 diff --git a/drawing/readwrite.lua b/drawing/readwrite.lua index 87a2fe1..0e0df1b 100644 --- a/drawing/readwrite.lua +++ b/drawing/readwrite.lua @@ -6,6 +6,7 @@ local sys = require 'sys' return function(update_freq, devices) local PLOT_SEC_BREAK = 20 local PLOT_HEIGHT = 56 + -- TODO currently this will find any block device local DEVICE_PATHS = sys.get_disk_paths(devices) local init_read_bytes, init_write_bytes = sys.get_total_disk_io(DEVICE_PATHS) diff --git a/main.lua b/main.lua index dff8401..5ee66bd 100644 --- a/main.lua +++ b/main.lua @@ -37,7 +37,14 @@ function conky_start(update_interval) local update_freq = 1 / update_interval local devices = {'sda', 'nvme0n1'} local battery = 'BAT0' - local fs_paths = {'/', '/boot', '/home', '/mnt/data', '/mnt/dcache', "/tmp"} + local fs_paths = { + {'/', 'root'}, + {'/boot', 'boot'}, + {'/home', 'home'}, + {'/mnt/data', 'data'}, + {'/mnt/dcache', 'dcache'}, + {'/tmp', 'tmpfs'} + } local mem = memory(update_freq) local rw = readwrite(update_freq, devices)