I actually just got around to solving this problem myself, the key is
looking at the "carrier" reported for each interface.
Previously I'd been displaying both up/down for both wired and
wireless interfaces which was an annoying waste of space.
Here's what I ended up with:
-- Initialize widget
netwidget = wibox.widget.textbox()
-- Register widget
vicious.register(netwidget, vicious.widgets.net,
function (widget, args)
local ethdown = args["{eth0 down_kb}"]
local ethup = args["{eth0 up_kb}"]
local ethactive = (tonumber(args["{eth0 carrier}"]) == 1)
local wifidown = args["{wlan0 down_kb}"]
local wifiup = args["{wlan0 up_kb}"]
local wifiactive = (tonumber(args["{wlan0 carrier}"]) == 1)
local down = ethdown
local up = ethup
local ifname = "wired"
if (not ethactive and wifiactive) then
down = wifidown
up = wifiup
ifname = "wifi"
end
return string.format('<span color="#CC9393">%.1f Kb/s</span> %s ' ..
'<span color="#7F9F7F">%.1f Kb/s</span>',
wifidown, ifname, wifiup)
end, 3)
You'll probably want to play with formatting, but hopefully that gives
you the idea.
Hope this helps!
~Will
On Mon, Apr 8, 2013 at 4:07 PM, Manuel Kasser <[email protected]> wrote:
> Hi there,
>
> I was wondering if someone has an idea how to solve my little problem:
>
> I have two networkinterfaces in my machine, WLAN and a wired connection.
> Depending on the place I am either the one or the other is in use.
>
> Though, as I have a network usage widget (the one that comes with
> vicious) in my wibox, I have to manually switch the used interface in my
> configuration code to get the network traffic of the used interface. Is
> there a way to use vicious' netwidget to monitor the traffic going over
> both of the interfaces (or just showing the one which is up) or do I
> have to write my own widget? I'm displaying the traffic down as well as
> up next to each other, if that's important in some way.
>
> Thanks in advance,
> Manuel
>
> --
> To unsubscribe, send mail to [email protected].
--
To unsubscribe, send mail to [email protected].