diff --git a/bumblebee/modules/traffic.py b/bumblebee/modules/traffic.py index 2eac453..250a1a7 100644 --- a/bumblebee/modules/traffic.py +++ b/bumblebee/modules/traffic.py @@ -6,6 +6,8 @@ Parameters: * traffic.exclude: Comma-separated list of interface prefixes to exclude (defaults to "lo,virbr,docker,vboxnet,veth") * traffic.states: Comma-separated list of states to show (prefix with "^" to invert - i.e. ^down -> show all devices that are not in state down) * traffic.showname: If set to False, hide network interface name (defaults to True) + * traffic.format: Format string for download/upload speeds. + Defaults to "{:.2f}" """ import time @@ -25,6 +27,7 @@ class Module(bumblebee.engine.Module): self._status = "" self._showname = bumblebee.util.asbool(self.parameter("showname", True)) + self._format = self.parameter("format", "{:.2f}") self._prev = {} self._states = {} self._lastcheck = 0 @@ -102,8 +105,10 @@ class Module(bumblebee.engine.Module): name = "traffic.{}-{}".format(direction, interface) widget = self.create_widget(widgets, name, attributes={"theme.minwidth": "1000.00MB"}) prev = self._prev.get(name, 0) - speed = bumblebee.util.bytefmt((int(data[direction]) - int(prev))/timediff) - txtspeed ='{0}/s'.format(speed) + speed = bumblebee.util.bytefmt( + (int(data[direction]) - int(prev))/timediff, + self._format) + txtspeed = '{0}/s'.format(speed) widget.full_text(txtspeed) self._prev[name] = data[direction]