[modules] Re-enable "disk" module
This commit is contained in:
parent
286aff2aa0
commit
bd0089dac0
4 changed files with 23 additions and 10 deletions
|
@ -12,29 +12,34 @@ def description():
|
|||
return "Shows free diskspace, total diskspace and the percentage of free disk space."
|
||||
|
||||
class Module(bumblebee.module.Module):
|
||||
def __init__(self, output, args):
|
||||
super(Module, self).__init__(args)
|
||||
self._path = args[0] if args else "/"
|
||||
def __init__(self, output, config):
|
||||
super(Module, self).__init__(output, config)
|
||||
self._path = self._config.parameter("disk.path", "/")
|
||||
|
||||
output.add_callback(module=self.__module__, button=1,
|
||||
cmd="nautilus {instance}")
|
||||
# TODO
|
||||
# output.add_callback(module=self.__module__, button=1,
|
||||
# cmd="nautilus {instance}")
|
||||
|
||||
def data(self):
|
||||
def widgets(self):
|
||||
st = os.statvfs(self._path)
|
||||
|
||||
self._size = st.f_frsize*st.f_blocks
|
||||
self._used = self._size - st.f_frsize*st.f_bavail
|
||||
self._perc = 100.0*self._used/self._size
|
||||
|
||||
return "{} {}/{} ({:05.02f}%)".format(self._path, bumblebee.util.bytefmt(self._used), bumblebee.util.bytefmt(self._size), self._perc)
|
||||
return bumblebee.output.Widget(self,
|
||||
"{} {}/{} ({:05.02f}%)".format(self._path,
|
||||
bumblebee.util.bytefmt(self._used),
|
||||
bumblebee.util.bytefmt(self._size), self._perc)
|
||||
)
|
||||
|
||||
def instance(self):
|
||||
return self._path
|
||||
|
||||
def warning(self):
|
||||
return self._perc > 80
|
||||
return self._perc > self._config.parameter("disk.warning", 80)
|
||||
|
||||
def critical(self):
|
||||
return self._perc > 90
|
||||
return self._perc > self._config.parameter("disk.critical", 90)
|
||||
|
||||
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue