bumblebee-status/bumblebee/engine.py

39 lines
1.1 KiB
Python
Raw Normal View History

import importlib
import bumblebee.theme
import bumblebee.output
import bumblebee.config
2016-11-05 06:47:22 +01:00
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