34 lines
1.1 KiB
Lua
34 lines
1.1 KiB
Lua
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
|
||
|