functional

This commit is contained in:
matt LLVW 2019-05-14 22:26:22 +02:00
parent 2be4549c15
commit 622f27f886
2 changed files with 5 additions and 8 deletions

View File

@ -76,7 +76,7 @@ Options:
-f, --fahrenheit Show temperatures in fahrenheit.
-s, --statusbar Show a statusbar with the time.
-b, --battery Show battery level widget ('minimal' turns off).
-i, --interface Select network interface [default: all].
-i, --interface=NAME Select network interface [default: all].
Colorschemes:
default
@ -118,7 +118,7 @@ Colorschemes:
if fahrenheit {
tempScale = w.Fahrenheit
}
netInterface, _ := args["--interface"].(string)
netInterface, _ = args["--interface"].(string)
return nil
}

View File

@ -38,7 +38,7 @@ func NewNetWidget(netInterface string) *NetWidget {
}
self.Title = " Network Usage "
if netInterface != "all" {
self.Title = fmt.Sprintf(" %s Usage ", netInterface)
self.Title = fmt.Sprintf(" %s Usage ", netInterface)
}
self.update()
@ -64,11 +64,8 @@ func (self *NetWidget) update() {
var totalBytesRecv uint64
var totalBytesSent uint64
for _, _interface := range interfaces {
// ignore VPN interface
if _interface.Name != "tun0" && self.NetInterface == "all" {
totalBytesRecv += _interface.BytesRecv
totalBytesSent += _interface.BytesSent
} else if _interface.Name == self.NetInterface {
// ignore VPN interface or filter interface by name
if (_interface.Name != "tun0" && self.NetInterface == "all") || (_interface.Name == self.NetInterface) {
totalBytesRecv += _interface.BytesRecv
totalBytesSent += _interface.BytesSent
}