aboutsummaryrefslogtreecommitdiffstats
path: root/.config/luastatus-scripts-dwm/ip.lua
diff options
context:
space:
mode:
Diffstat (limited to '.config/luastatus-scripts-dwm/ip.lua')
-rw-r--r--.config/luastatus-scripts-dwm/ip.lua20
1 files changed, 20 insertions, 0 deletions
diff --git a/.config/luastatus-scripts-dwm/ip.lua b/.config/luastatus-scripts-dwm/ip.lua
new file mode 100644
index 0000000..37bc43a
--- /dev/null
+++ b/.config/luastatus-scripts-dwm/ip.lua
@@ -0,0 +1,20 @@
+widget = {
+ plugin = 'network-linux',
+ cb = function(t)
+ local r = {}
+ for iface, params in pairs(t) do
+ local addr = params.ipv4
+ if addr then
+ -- strip out "label" from the interface name
+ iface = iface:gsub(':.*', '')
+ -- strip out "zone index" from the address
+ addr = addr:gsub('%%.*', '')
+
+ if iface ~= 'lo' then
+ r[#r + 1] = string.format('[%s: %s]', iface, addr)
+ end
+ end
+ end
+ return r
+ end,
+}