[modules] Re-enable "disk" module
This commit is contained in:
parent
286aff2aa0
commit
bd0089dac0
4 changed files with 23 additions and 10 deletions
|
@ -48,7 +48,12 @@ class Module(object):
|
||||||
def state(self):
|
def state(self):
|
||||||
return "default"
|
return "default"
|
||||||
|
|
||||||
|
def instance(self):
|
||||||
|
return None
|
||||||
|
|
||||||
def next(self):
|
def next(self):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4
|
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4
|
||||||
|
|
|
@ -12,29 +12,34 @@ def description():
|
||||||
return "Shows free diskspace, total diskspace and the percentage of free disk space."
|
return "Shows free diskspace, total diskspace and the percentage of free disk space."
|
||||||
|
|
||||||
class Module(bumblebee.module.Module):
|
class Module(bumblebee.module.Module):
|
||||||
def __init__(self, output, args):
|
def __init__(self, output, config):
|
||||||
super(Module, self).__init__(args)
|
super(Module, self).__init__(output, config)
|
||||||
self._path = args[0] if args else "/"
|
self._path = self._config.parameter("disk.path", "/")
|
||||||
|
|
||||||
output.add_callback(module=self.__module__, button=1,
|
# TODO
|
||||||
cmd="nautilus {instance}")
|
# output.add_callback(module=self.__module__, button=1,
|
||||||
|
# cmd="nautilus {instance}")
|
||||||
|
|
||||||
def data(self):
|
def widgets(self):
|
||||||
st = os.statvfs(self._path)
|
st = os.statvfs(self._path)
|
||||||
|
|
||||||
self._size = st.f_frsize*st.f_blocks
|
self._size = st.f_frsize*st.f_blocks
|
||||||
self._used = self._size - st.f_frsize*st.f_bavail
|
self._used = self._size - st.f_frsize*st.f_bavail
|
||||||
self._perc = 100.0*self._used/self._size
|
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):
|
def instance(self):
|
||||||
return self._path
|
return self._path
|
||||||
|
|
||||||
def warning(self):
|
def warning(self):
|
||||||
return self._perc > 80
|
return self._perc > self._config.parameter("disk.warning", 80)
|
||||||
|
|
||||||
def critical(self):
|
def critical(self):
|
||||||
return self._perc > 90
|
return self._perc > self._config.parameter("disk.critical", 90)
|
||||||
|
|
||||||
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4
|
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4
|
||||||
|
|
|
@ -24,6 +24,9 @@ class Widget(object):
|
||||||
def name(self):
|
def name(self):
|
||||||
return self._obj.__module__
|
return self._obj.__module__
|
||||||
|
|
||||||
|
def instance(self):
|
||||||
|
rv = getattr(self._obj, "instance")()
|
||||||
|
|
||||||
def text(self):
|
def text(self):
|
||||||
return self._text
|
return self._text
|
||||||
|
|
||||||
|
|
|
@ -62,7 +62,7 @@ class Output(bumblebee.output.Output):
|
||||||
"color": theme.color(widget),
|
"color": theme.color(widget),
|
||||||
"background": theme.background(widget),
|
"background": theme.background(widget),
|
||||||
"name": widget.name(),
|
"name": widget.name(),
|
||||||
"instance": getattr(widget, "instance", None),
|
"instance": widget.instance(),
|
||||||
"separator": theme.default_separators(widget),
|
"separator": theme.default_separators(widget),
|
||||||
"separator_block_width": theme.separator_block_width(widget),
|
"separator_block_width": theme.separator_block_width(widget),
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue