2016-11-04 21:03:12 +01:00
|
|
|
import importlib
|
|
|
|
import bumblebee.theme
|
2016-11-04 21:41:22 +01:00
|
|
|
import bumblebee.output
|
2016-11-05 06:47:22 +01:00
|
|
|
import bumblebee.modules
|
2016-11-04 21:03:12 +01:00
|
|
|
|
|
|
|
class Engine:
|
2016-11-05 08:11:08 +01:00
|
|
|
def __init__(self, config):
|
2016-11-04 21:03:12 +01:00
|
|
|
self._modules = []
|
2016-11-05 08:11:08 +01:00
|
|
|
self._config = config
|
|
|
|
self._theme = bumblebee.theme.Theme(config)
|
|
|
|
self._output = bumblebee.output.output(config)
|
2016-11-04 21:03:12 +01:00
|
|
|
|
2016-11-05 14:26:02 +01:00
|
|
|
def load_module(self, modulespec):
|
|
|
|
name = modulespec["name"]
|
2016-11-04 21:03:12 +01:00
|
|
|
module = importlib.import_module("bumblebee.modules.{}".format(name))
|
2016-11-05 14:26:02 +01:00
|
|
|
return getattr(module, "Module")(self._output, self._config, modulespec["alias"])
|
2016-11-04 21:03:12 +01:00
|
|
|
|
|
|
|
def load_modules(self):
|
2016-11-05 08:11:08 +01:00
|
|
|
for m in self._config.modules():
|
2016-11-04 21:03:12 +01:00
|
|
|
self._modules.append(self.load_module(m))
|
|
|
|
|
|
|
|
def run(self):
|
2016-11-05 08:59:43 +01:00
|
|
|
self._output.start()
|
2016-11-04 21:03:12 +01:00
|
|
|
|
|
|
|
while True:
|
2016-11-05 08:59:43 +01:00
|
|
|
self._theme.begin()
|
2016-11-04 21:03:12 +01:00
|
|
|
for m in self._modules:
|
2016-11-05 08:59:43 +01:00
|
|
|
self._output.draw(m.widgets(), self._theme)
|
|
|
|
self._output.flush()
|
|
|
|
self._output.wait()
|
2016-11-04 21:03:12 +01:00
|
|
|
|
2016-11-05 08:59:43 +01:00
|
|
|
self._output.stop()
|
2016-11-04 21:03:12 +01:00
|
|
|
|
|
|
|
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4
|