[modules] Add support for disk utilization

Add a new module "disk" that takes an optional parameter (the path) and
displays free & total disk space, along with the usage percentage.

Also, added Tunnel/VPN support to the themeing of the "net" module.
This commit is contained in:
Tobias Witek 2016-10-31 13:34:48 +01:00
parent b235ae88a4
commit bb6ca556c7
5 changed files with 59 additions and 14 deletions

View file

@ -19,11 +19,15 @@ class Module(bumblebee.module.Module):
self._state = "down"
addr = []
if netifaces.AF_INET in netifaces.ifaddresses(self._intf):
for ip in netifaces.ifaddresses(self._intf)[netifaces.AF_INET]:
if "addr" in ip and ip["addr"] != "":
addr.append(ip["addr"])
self._state = "up"
try:
if netifaces.AF_INET in netifaces.ifaddresses(self._intf):
for ip in netifaces.ifaddresses(self._intf)[netifaces.AF_INET]:
if "addr" in ip and ip["addr"] != "":
addr.append(ip["addr"])
self._state = "up"
except Exception as e:
self._state = "down"
addr = []
return "{} {} {}".format(self._intf, self._state, ", ".join(addr))
@ -48,9 +52,14 @@ class Module(bumblebee.module.Module):
self._cache["wlan{}".format(intf)] = False
return self._cache["wlan{}".format(intf)]
def _istunnel(self, intf):
return intf.startswith("tun")
def state(self):
t = "wireless" if self._iswlan(self._intf) else "wired"
t = "tunnel" if self._istunnel(self._intf) else t
return "{}-{}".format(t, self._state)
def warning(self):