diff --git a/bumblebee-status b/bumblebee-status index fed93c6..a52691c 100755 --- a/bumblebee-status +++ b/bumblebee-status @@ -31,7 +31,8 @@ def handle_input(output): modules[event['name']] = True except ValueError: pass - output.draw('patch', modules.keys()) + output.update(modules.keys()) + output.draw('statusline') poll.unregister(sys.stdin.fileno()) @@ -55,8 +56,7 @@ def main(): output.modules(modules) output.draw('start') while True: - for module in modules: - module.update() + output.update() output.draw('statusline') output.wait(config.interval()) output.draw('stop') diff --git a/core/output.py b/core/output.py index c52e51b..925456d 100644 --- a/core/output.py +++ b/core/output.py @@ -5,7 +5,7 @@ import time class i3(object): def __init__(self): self._modules = [] - self._status = [] + self._status = {} def modules(self, modules=None): if not modules: @@ -31,20 +31,23 @@ class i3(object): def stop(self): return { 'suffix': '\n]' } - def patch(self, affected_modules): - pass # TODO - - def statusline(self): - self._status = [] + def update(self, affected_modules=None): for module in self._modules: + module.update() + self._status[module] = [] for widget in module.widgets(): - self._status.append({ + self._status[module].append({ 'full_text': widget.full_text(), 'instance': widget.id(), 'name': module.id(), }) + + def statusline(self): + widgets = [] + for module in self._modules: + widgets += self._status[module] return { - 'data': self._status, + 'data': widgets, 'suffix': ',' } diff --git a/tests/core/test_output.py b/tests/core/test_output.py index 88be280..ebd4e6b 100644 --- a/tests/core/test_output.py +++ b/tests/core/test_output.py @@ -14,9 +14,6 @@ class i3(unittest.TestCase): widget.full_text.return_value = "test" self.someModule = TestModule(widgets=[widget, widget, widget]) - def tearDown(self): - pass - def test_start(self): all_data = self.i3.start() data = all_data['data'] @@ -52,6 +49,7 @@ class i3(unittest.TestCase): def test_statusline(self): self.i3.modules([ self.someModule, self.someModule, self.someModule ]) + self.i3.update() data = self.i3.statusline() self.assertEqual(len(self.someModule.widgets())*3, len(data['data']), 'wrong number of widgets')