From ecf4f73388ffcd44bf6071633b6282df8573ef54 Mon Sep 17 00:00:00 2001 From: ndwarshuis Date: Sun, 18 Jul 2021 19:27:41 -0400 Subject: [PATCH] ENH dynamically grab physical interfaces --- drawing/Network.lua | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/drawing/Network.lua b/drawing/Network.lua index 1a3e269..e0a8a05 100644 --- a/drawing/Network.lua +++ b/drawing/Network.lua @@ -5,8 +5,17 @@ local Geometry = require 'Geometry' return function(update_freq) local PLOT_SEC_BREAK = 20 local PLOT_HEIGHT = 56 - -- TODO ensure these interfaces actually exist - local INTERFACES = {'enp7s0f1', 'wlp0s20f3'} + + local get_interfaces = function() + local s = Util.execute_cmd('realpath /sys/class/net/* | grep -v virtual') + local interfaces = {} + for iface in string.gmatch(s, '/([^/\n]+)\n') do + interfaces[#interfaces + 1] = iface + end + return interfaces + end + + local INTERFACES = get_interfaces() ----------------------------------------------------------------------------- -- header