3.8: Add wireless module based on basiciw
This commit is contained in:
parent
c60d2fd3df
commit
1680293e56
24
README.md
24
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
|
||||
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user