bumblebee-status/bumblebee/engine.py
Tobi-wan Kenobi 2f3f171ca5 [core] Remove alias from module
Hide alias concept for modules in the engine. That way, the individual
modules never get to know about whether a module has been aliased or
not.

see #23
2016-12-02 18:53:34 +01:00

38 lines
1.1 KiB
Python

import importlib
import bumblebee.theme
import bumblebee.output
import bumblebee.config
import bumblebee.modules
class Engine:
def __init__(self, config):
self._modules = []
self._config = config
self._theme = bumblebee.theme.Theme(config)
self._output = bumblebee.output.output(config)
def load_module(self, modulespec):
name = modulespec["name"]
module = importlib.import_module("bumblebee.modules.{}".format(name))
cfg = bumblebee.config.ModuleConfig(self._config, name, modulespec["alias"])
obj = getattr(module, "Module")(self._output, cfg)
obj.register_callbacks()
return obj
def load_modules(self):
for m in self._config.modules():
self._modules.append(self.load_module(m))
def run(self):
self._output.start()
while True:
self._theme.begin()
for m in self._modules:
self._output.draw(m.widgets(), self._theme)
self._output.flush()
self._output.wait()
self._output.stop()
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4