Commit 5af04ca5 authored by Vincent Tam's avatar Vincent Tam

Conky : Reconnaissance auto de l'interface actif de réseau

parent 8f30761f
......@@ -59,7 +59,7 @@ conky.config = {
own_window_colour = '#000000',
minimum_width = 240, minimum_height = 0,
alignment = 'top_right',
lua_load = '/home/vin100/dotfiles/conky/myscript.lua'
};
conky.text = [[
${font sans-serif:bold:size=10}SYSTEM ${hr 2}
......@@ -87,9 +87,9 @@ ${fs_bar /}
${font Ubuntu:bold:size=10}NETWORK ${hr 2}
${font}Local IPs: ${alignr} External IP:
${execi 1000 ip a | grep inet | grep -vw lo | grep -v inet6 | cut -d \/ -f1 | sed 's/[^0-9\.]*//g'} ${alignr}${execi 1000 wget -q -O- http://ipecho.net/plain | head -1 | sed 's/[^0-9\.]*//g'}
${font}Down: ${downspeed wlp3s0f0} ${alignr} Up: ${upspeed wlp3s0f0}
${color lightgray}${downspeedgraph wlp3s0f0 60,120} ${alignr} ${upspeedgraph wlp3s0f0 60,120}$color
${lua myaddr} ${alignr}${execi 1000 curl http://ipecho.net/plain | grep -Po '(\.?[0-9]{2,3}){4}' || echo 'Not found!'}
${font}Down: ${lua myspeed down} ${alignr} Up: ${lua myspeed up}
${color lightgray}${lua myspeedgraph down 60 120} ${alignr} ${lua myspeedgraph up 60 120}$color
${font sans-serif:bold:size=10}TOP PROCESSES ${hr 2}
${font}Name $alignr PID CPU% MEM%
${top name 1} $alignr ${top pid 1} ${top cpu 1} ${top mem 1}
......
-- Find local IP address according to active connections
function conky_myaddr()
return conky_parse('${addr ' .. findInterface() .. '}')
end
-- Find up/download speed
function conky_myspeed(upordown)
print(findInterface())
return conky_parse('${' .. upordown .. 'speed ' .. findInterface() .. '}')
end
-- Generate up/download speed graph
function conky_myspeedgraph(upordown, h, w)
return conky_parse('${'..upordown..'speedgraph '..findInterface()..' '..h..','..w..'}')
end
-- Find the string representing the connection's interface (e.g. eth0)
function findInterface()
local handle = io.popen('ip a | grep "state UP" | cut -d: -f2 | tr -d " "')
local result = handle:read('*a'):gsub('\n$','')
handle:close()
return result
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment