[modules] Add module-specific configuration
Big oversight in my previous commits: Widgets need to be able to have specific configurations (i.e. the path for different instances of the "disk" module has to be different). To account for that, it is now possible to assign an "alias" to a module instance using ":" (for example: -m "disk:home"). This alias is then used for the configuration parameter resolution automatically, for example: -m disk:home -p home.path=/home As a consequence, parameter names in the module code are now relative to the module, which means: shorter!
This commit is contained in:
parent
9f9b27ad7a
commit
4e648cf009
11 changed files with 62 additions and 40 deletions
|
@ -12,9 +12,9 @@ def description():
|
|||
return "Shows free diskspace, total diskspace and the percentage of free disk space."
|
||||
|
||||
class Module(bumblebee.module.Module):
|
||||
def __init__(self, output, config):
|
||||
super(Module, self).__init__(output, config)
|
||||
self._path = self._config.parameter("disk.path", "/")
|
||||
def __init__(self, output, config, alias):
|
||||
super(Module, self).__init__(output, config, alias)
|
||||
self._path = self._config.parameter("path", "/")
|
||||
|
||||
# TODO
|
||||
# output.add_callback(module=self.__module__, button=1,
|
||||
|
@ -33,13 +33,10 @@ class Module(bumblebee.module.Module):
|
|||
bumblebee.util.bytefmt(self._size), self._perc)
|
||||
)
|
||||
|
||||
def instance(self, widget):
|
||||
return self._path
|
||||
|
||||
def warning(self, widget):
|
||||
return self._perc > self._config.parameter("disk.warning", 80)
|
||||
return self._perc > self._config.parameter("warning", 80)
|
||||
|
||||
def critical(self, widget):
|
||||
return self._perc > self._config.parameter("disk.critical", 90)
|
||||
return self._perc > self._config.parameter("critical", 90)
|
||||
|
||||
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue