forked from kescherCode/conky-config
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathluaFunc.lua
36 lines (35 loc) · 1.79 KB
/
luaFunc.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
active_network_interface = false
function conky_drawnetworks(max_ifaces)
local active_ifaces = {}
if active_network_interface == false or tonumber(conky_parse("$updates")) % 2 == 0 then
local ifaces = io.popen('ip link | grep -Po --regexp "(?<=[0-9]: ).*"')
for line in ifaces:lines() do
if string.find(line, "<BROADCAST") and string.find(line, ",UP") then
local iface = string.gsub(string.match(line, "^.*:"), ":", "")
table.insert(active_ifaces, iface)
end
end
ifaces:close()
if table.maxn(active_ifaces) >= 1 then
local draw_other_ifaces = ''
for i, iface in pairs(active_ifaces) do
if i <= tonumber(max_ifaces) then
draw_other_ifaces = draw_other_ifaces
.. " ${color0}" .. iface .. "${alignr}${color1}${addrs " .. iface .. "}" .. "\n\n"
.. " ${color0}▼ ${color1}${downspeed " .. iface .. "}/s ${alignr}${color0}▲ ${color1}${upspeed " .. iface .. "}/s\n"
.. " ${color1}${downspeedgraph " .. iface .. " 50,100 00592f 00b386 -t -l}"
.. "${alignr}${upspeedgraph " .. iface .. " 50,100 00592f 00b386 -t -l}"
.. "\n"
if i < table.maxn(active_ifaces) and i ~= tonumber(max_ifaces) then
draw_other_ifaces = draw_other_ifaces .. " ${voffset -15}$color0${stippled_hr 2}\n"
end
end
end
active_network_interface = draw_other_ifaces
return active_network_interface
else
active_network_interface = '${color2}No interfaces are connected'
end
end
return active_network_interface
end