2016-11-04 21:03:12 +01:00
|
|
|
import os
|
|
|
|
import sys
|
|
|
|
import glob
|
|
|
|
import pkgutil
|
|
|
|
import textwrap
|
|
|
|
import argparse
|
|
|
|
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 08:11:08 +01:00
|
|
|
def load_module(self, name):
|
2016-11-04 21:03:12 +01:00
|
|
|
module = importlib.import_module("bumblebee.modules.{}".format(name))
|
2016-11-05 08:11:08 +01:00
|
|
|
return getattr(module, "Module")(self._output, self._config)
|
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 register_event(self, eventspec):
|
2016-11-05 08:11:08 +01:00
|
|
|
return
|
|
|
|
# TODO
|
2016-11-04 21:03:12 +01:00
|
|
|
event = eventspec.split(self._args.split)
|
|
|
|
if len(event) < 3:
|
|
|
|
raise Exception("invalid click event format, expected 3 parameters")
|
|
|
|
self._output.add_callback(
|
|
|
|
module = event[0],
|
|
|
|
button = int(event[1]),
|
|
|
|
cmd = event[2],
|
|
|
|
)
|
|
|
|
|
|
|
|
def register_events(self):
|
2016-11-05 08:11:08 +01:00
|
|
|
return
|
|
|
|
# TODO
|
2016-11-04 21:03:12 +01:00
|
|
|
for e in self._args.events:
|
|
|
|
self.register_event(e)
|
|
|
|
|
|
|
|
def run(self):
|
|
|
|
print self._output.start()
|
|
|
|
|
|
|
|
while True:
|
|
|
|
# improve this
|
|
|
|
self._theme.reset()
|
|
|
|
for m in self._modules:
|
|
|
|
self._output.add(m, self._theme)
|
|
|
|
self._theme.next()
|
|
|
|
print self._output.get()
|
|
|
|
sys.stdout.flush()
|
2016-11-04 21:10:21 +01:00
|
|
|
self._output.wait(self._args.interval)
|
2016-11-04 21:03:12 +01:00
|
|
|
|
|
|
|
print self._output.stop()
|
|
|
|
|
|
|
|
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4
|