From 1680293e561a65634c83d3576430e82406c38cac Mon Sep 17 00:00:00 2001 From: enkore Date: Fri, 8 Mar 2013 19:51:55 +0100 Subject: [PATCH] 3.8: Add wireless module based on basiciw --- README.md | 24 ++++++++++++++++++++++++ i3pystatus/network.py | 7 ++++++- setup.py | 2 +- 3 files changed, 31 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 85ddc91..b755bd4 100644 --- a/README.md +++ b/README.md @@ -105,6 +105,7 @@ Available formatters for format and alert_format_\*: * `alert_format_title` — (default: `Low battery`) * `alert_format_body` — (default: `Battery {battery_ident} has only {percentage:.2f}% ({remaining_hm}) remaining!`) * `alert_percentage` — (default: `10`) +* `path` — (default: `None`) @@ -333,6 +334,29 @@ AMD is currently not supported as they can only report a relative temperature, w +### wireless + + +Display network information about a interface. + +Requires the PyPI packages `netifaces-py3` and `basiciw`. + +This is based on the network module, so all options and formatters are +the same, except for these additional formatters: +* {essid} ESSID of currently connected wifi +* {freq} Current frequency +* {quality} Link quality in percent + + +* `interface` — Interface to obtain information for, i.e. eth0 (default: `eth0`) +* `format_up` — (default: `{interface}: {v4}`) +* `color_up` — (default: `#00FF00`) +* `format_down` — (default: `{interface}`) +* `color_down` — (default: `#FF0000`) +* `name` — (default: `eth0`) + + + ## Contribute diff --git a/i3pystatus/network.py b/i3pystatus/network.py index 0dd8350..c007ccf 100644 --- a/i3pystatus/network.py +++ b/i3pystatus/network.py @@ -80,7 +80,7 @@ class Network(IntervalModule): "mac": netifaces.ifaddresses(self.interface)[netifaces.AF_PACKET][0]["addr"], } - def run(self): + def collect(self): info = netifaces.ifaddresses(self.interface) up = netifaces.AF_INET in info or netifaces.AF_INET6 in info fdict = dict(zip_longest(["v4", "v4mask", "v4cidr", "v6", "v6mask", "v6cidr"], [], fillvalue="")) @@ -103,6 +103,11 @@ class Network(IntervalModule): format = self.format_down color = self.color_down + return (color, format, fdict, up) + + def run(self): + color, format, fdict, up = self.collect() + self.output = { "full_text": format.format(**fdict), "color": color, diff --git a/setup.py b/setup.py index 181b528..8253b74 100755 --- a/setup.py +++ b/setup.py @@ -3,7 +3,7 @@ from setuptools import setup setup(name="i3pystatus", - version="3.7", + version="3.8", description="Like i3status, this generates status line for i3bar / i3wm", url="http://github.com/enkore/i3pystatus", license="MIT",