Files
system_info/.config/conky/nets.lua
2026-03-01 01:39:46 +03:00

34 lines
1.1 KiB
Lua
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
function conky_get_network_info()
-- получаем список интерфейсов с IPv4-адресами
local f = io.popen("ip -o -4 addr show | awk '{print $2,$4}'")
local output = f:read("*all")
f:close()
local result = ""
for line in output:gmatch("[^\r\n]+") do
local iface, addr = line:match("([^%s]+)%s+([^%s]+)")
if iface then
-- получаем MAC-адрес
local f_mac = io.popen("cat /sys/class/net/" .. iface .. "/address 2>/dev/null")
local mac = f_mac:read("*l") or "N/A"
f_mac:close()
local down = conky_parse("${downspeed " .. iface .. "}")
local up = conky_parse("${upspeed " .. iface .. "}")
result = result ..
string.format("${color white}%s${color} ", iface) ..
string.format("${color red}IP: %s\n", addr) ..
string.format("${color red}MAC: %s\n", mac) ..
string.format("${color red} ↓%s ↑ %s\n\n", down, up)
end
end
if result == "" then
result = "EMPTY"
end
return result
end