From da3fa23470e098fb9df326ad4fe013fc61ae6cd2 Mon Sep 17 00:00:00 2001 From: ache Date: Sat, 11 Nov 2017 03:29:23 +0100 Subject: Network info widget update --- rc.lua | 51 +++++++++++++++++++++++++++++++++------------------ 1 file changed, 33 insertions(+), 18 deletions(-) diff --git a/rc.lua b/rc.lua index ec5d854..fa5fb08 100644 --- a/rc.lua +++ b/rc.lua @@ -252,24 +252,39 @@ function act() end) --{{ Network - awful.spawn.easy_async("bash -c \"ip r | grep default | cut -d' ' -f 5,7\"", - function(stdout, stderr, reason, exit_code) - if not (stdout == "" or stdout == "\n") then - tmpPos = string.find(stdout, " ") - interface = string.sub(stdout, 0, tmpPos) - ip = string.sub(stdout,tmpPos, string.len(stdout)-1) - mynetworkwidget:set_text ( ip .. "@" .. interface) - awful.spawn.easy_async("bash -c \"iwconfig 2>1 | grep -v 'no wireless' | grep " .. interface .. " | cut -d':' -f 2 | cut -d'\\\"' -f2\"", - function(essid, stderr2, reason2, exit_code2) - awful.spawn.easy_async("bash -c \"iwconfig 2>1 | grep -v 'no wireless' | grep Signal | cut -d'=' -f 3 | cut -d' ' -f 1\"", - function(signal, stderr3, reason3, exit_code3) - mynetworkwidget:set_text ( ip .. "@" .. string.sub(essid, 0, string.len(essid)-1) .. "#" .. signal) - end) - end) - else - mynetworkwidget:set_markup( "ip" ) - end - end) + awful.spawn.easy_async("bash -c \"ip r | grep default | head -n 1 | sed s/.*dev/sed/ | cut -d' ' -f 2\"", + function(interface, stderr, reason, exit_code) + if not ( interface == "" or interface == "\n") then + interface = string.gsub(interface, "\n", "") + awful.spawn.easy_async("bash -c \"ip r | grep 'dev " .. interface .. "' | grep src | head -n 1 | sed 's/.*src/src/' | cut -d' ' -f 2 | cut -z -f1\"", + function(ip, stderr2, reason3, exit_code3) + toShow = "" + if not ( ip == "" or ip == "\n") then + ip = string.gsub(ip, "\n", "") + toShow = ip .. "@" + end + awful.spawn.easy_async("bash -c \"iwconfig wlp3s0 2>1 | grep -v 'no wireless' | grep wlp3s0 | cut -d'\\\"' -f 2 \"", + function(essid, stderr2, reason2, exit_code2) + if not (essid == "" ) then + essid = string.gsub(essid, "\n", "") + awful.spawn.easy_async("bash -c \"iwconfig " .. interface .. " 2>1 | grep -v 'no wireless' | grep Signal | cut -d'=' -f 3 | cut -d' ' -f 1\"", + function(signal, stderr3, reason3, exit_code3) + signal = string.gsub(signal, "\n", "") + mynetworkwidget:set_text ( ip .. "@" .. essid .. "#" .. signal) + end + ) + else + mynetworkwidget:set_text ( toShow .. interface ) + end + end + ) + end + ) + else + mynetworkwidget:set_markup( "ip" ) + end + end + ) -- cgit v1.2.3