diff --git a/README.rst b/README.rst index 1078676..ccf782c 100644 --- a/README.rst +++ b/README.rst @@ -63,6 +63,7 @@ Contributors * philipdexter * sbrunner * siikamiika +* simon04 * talwrii * tomkenmag * tomxtobin @@ -79,6 +80,7 @@ next * `cpu\_usage\_bar`_: Add multicore support * `network`_: Add unknown_up setting * `parcel`_: Document lxml dependency +* Added `network\_traffic`_ module 3.30 ++++ @@ -439,7 +441,7 @@ Settings: :alert_format_title: The title of the notification, all formatters can be used (default: ``Low battery``) :alert_format_body: The body text of the notification, all formatters can be used (default: ``Battery {battery_ident} has only {percentage:.2f}% ({remaining:%E%hh:%Mm}) remaining!``) :path: Override the default-generated path (default: ``None``) -:status: A dictionary mapping ('DIS', 'CHR', 'FULL') to alternative names (default: ``{'DIS': 'DIS', 'CHR': 'CHR', 'FULL': 'FULL'}``) +:status: A dictionary mapping ('DIS', 'CHR', 'FULL') to alternative names (default: ``{'DIS': 'DIS', 'FULL': 'FULL', 'CHR': 'CHR'}``) :color: The text color (default: ``#ffffff``) :full_color: The full color (default: ``#00ff00``) :charging_color: The charging color (default: ``#00ff00``) @@ -828,7 +830,7 @@ Settings: :host: (default: ``localhost``) :port: MPD port (default: ``6600``) :format: formatp string (default: ``{title} {status}``) -:status: Dictionary mapping pause, play and stop to output (default: ``{'play': '▶', 'pause': '▷', 'stop': '◾'}``) +:status: Dictionary mapping pause, play and stop to output (default: ``{'pause': '▷', 'stop': '◾', 'play': '▶'}``) :color: The color of the text (default: ``#FFFFFF``) :interval: (default: ``1``) @@ -871,6 +873,33 @@ Settings: +network_traffic ++++++++++++++++ + + +Network traffic per interface, i.e., packets/bytes sent/received per second. + +Requires the PyPI packages `psutil`. + +Available formatters: + +* `{interface}` — the configured network interface +* `{bytes_sent}` — bytes sent per second (divided by divisor) +* `{bytes_recv}` — bytes received per second (divided by divisor) +* `{packets_sent}` — bytes sent per second (divided by divisor) +* `{packets_recv}` — bytes received per second (divided by divisor) + + +Settings: + +:format: format string (default: ``{interface} ↗{bytes_sent}kB/s ↘{bytes_recv}kB/s``) +:interface: network interface (default: ``eth0``) +:divisor: divide all byte values by this value (default: ``1024``) +:round_size: defines number of digits in round (default: ``None``) +:interval: (default: ``1``) + + + now_playing +++++++++++ @@ -896,7 +925,7 @@ Requires python-dbus available from every distros' package manager. Settings: :player: Player name (default: ``None``) -:status: Dictionary mapping pause, play and stop to output text (default: ``{'play': '▶', 'pause': '▷', 'stop': '◾'}``) +:status: Dictionary mapping pause, play and stop to output text (default: ``{'pause': '▷', 'stop': '◾', 'play': '▶'}``) :color: Text color (default: ``#FFFFFF``) :format: formatp string (default: ``{title} {status}``) :interval: (default: ``1``) @@ -1022,7 +1051,7 @@ Settings: :mail_brackets: Display unread message count in square-brackets. (default: ``False``) :title_maxlen: Maximum number of characters to display in title. (default: ``80``) :interval: Update interval. (default: ``300``) -:status: New message indicator. (default: ``{'new_mail': '✉', 'no_mail': ''}``) +:status: New message indicator. (default: ``{'no_mail': '', 'new_mail': '✉'}``) diff --git a/README.tpl.rst b/README.tpl.rst index 9fcab43..567b824 100644 --- a/README.tpl.rst +++ b/README.tpl.rst @@ -63,6 +63,7 @@ Contributors * philipdexter * sbrunner * siikamiika +* simon04 * talwrii * tomkenmag * tomxtobin @@ -79,6 +80,7 @@ next * `cpu\_usage\_bar`_: Add multicore support * `network`_: Add unknown_up setting * `parcel`_: Document lxml dependency +* Added `network\_traffic`_ module 3.30 ++++ diff --git a/i3pystatus/network_traffic.py b/i3pystatus/network_traffic.py index 14086fc..b4d2107 100644 --- a/i3pystatus/network_traffic.py +++ b/i3pystatus/network_traffic.py @@ -34,7 +34,7 @@ class NetworkTraffic(IntervalModule): def run(self): pnic_before = self.pnic self.pnic = psutil.net_io_counters(pernic=True)[self.interface] - if not pnic_before: return None + if not pnic_before: return cdict = { "bytes_sent": (self.pnic.bytes_sent - pnic_before.bytes_sent) / self.divisor, "bytes_recv": (self.pnic.bytes_recv - pnic_before.bytes_recv) / self.divisor,