You are not logged in.
Hello. I'm new to Awesome and Lua, but I already like the WM.
My concern is network statistics. I connect the Internet via USB-Tethering and each time I get somewhat different interface name: it can be enp0s20u4, another time (or with different device) it might be enp0s20u2 but generally it is enp0sXXuY. I want my network widget to show net stats without specifying the interface names in advance. (I'm trying to setup vicious.net widget for that purpose).
I guess I should set up WM to catch signal every time connections change to re-register the widget, but I have no idea how.
Anyway, if the widget could just list stats on all connected interfaces, I think that would work as well.
Curiously, the state of those interfaces is never UP but UNKNOWN:
~ » ip link
...
enp0s20u4: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UNKNOWN mode DEFAULT group default qlen 1000
Of course if manually put the interface name, it works just fine
vicious.register(netwidget, vicious.widgets.net, "D:${enp0s20u4 down_kb}", 1)
so the problem is to detect the name when it's connected.
Last edited by The_Keeper (2016-11-21 05:15:48)
Offline
The state is in the bracketed array:
<BROADCAST,MULTICAST,**UP**,LOWER_UP>
Offline
So, I've tried to catch dbus-singals of NetworkManager, but I can't get all the relevant data. According to NetworkManager docs DeviceAdded and DeviceRemoved signals should return path to the device. Here is my rc.lua with comments:
local dbus=dbus
...
dbus.add_match("system", "type=signal,interface='org.freedesktop.NetworkManager',member='DeviceRemoved'")
dbus.add_match("system", "type=signal,interface='org.freedesktop.NetworkManager',member='DeviceAdded'")
dbus.connect_signal(
"org.freedesktop.NetworkManager",
function(...)
local data = {...}
local sender=data[1] -- here is signal info (type, interface, etc)
local state=data[2] -- here should be path to device, but there's none: data is one-element table
-- I've tried to get interface name from /sys/class/net, but it seems like NetworkManager
-- needs some time to update those (new device name is usb0, if any):
local p = assert(io.popen("ls /sys/class/net","r"))
local s = p:read('*all')
naughty.notify({ text=tostring(s),timeout = 10})
end)
Any suggestions?
Offline
Of course, I can just read /sys/class/net on each refresh, but I suppose it would be an overhead on system resources. Would that really be significantly worse that dbus way?
Offline