[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
|
@ -2,6 +2,7 @@ import os
|
|||
import pkgutil
|
||||
import importlib
|
||||
|
||||
import bumblebee.config
|
||||
import bumblebee.modules
|
||||
|
||||
def modules():
|
||||
|
@ -32,9 +33,11 @@ class ModuleDescription(object):
|
|||
return "n/a"
|
||||
|
||||
class Module(object):
|
||||
def __init__(self, output, config):
|
||||
self._config = config
|
||||
def __init__(self, output, config, alias=None):
|
||||
self._output = output
|
||||
self._alias = alias
|
||||
name = "{}.".format(alias if alias else self.__module__.split(".")[-1])
|
||||
self._config = bumblebee.config.ModuleConfig(config, name)
|
||||
|
||||
def critical(self, widget):
|
||||
return False
|
||||
|
@ -46,6 +49,6 @@ class Module(object):
|
|||
return "default"
|
||||
|
||||
def instance(self, widget):
|
||||
return None
|
||||
return self._alias if self._alias else self.__module__.split(".")[-1]
|
||||
|
||||
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue