[core/output] Add initial version of i3bar output

Add output handler for i3bar protocol and add some tests for it. Right
now, it only support start and end.

see #23
This commit is contained in:
Tobi-wan Kenobi 2016-12-04 12:26:20 +01:00
parent a2c6214baa
commit 6f52825ef0
5 changed files with 59 additions and 6 deletions

View file

@ -19,7 +19,8 @@ class Engine(object):
This class connects input/output, instantiates all
required modules and drives the "event loop"
"""
def __init__(self, config):
def __init__(self, config, output=None):
self._output = output
self._running = True
self._modules = []
self.load_modules(config.modules())
@ -45,7 +46,10 @@ class Engine(object):
def run(self):
"""Start the event loop"""
self._output.start()
while self.running():
pass
self._output.stop()
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4

21
bumblebee/output.py Normal file
View file

@ -0,0 +1,21 @@
# pylint: disable=R0201
"""Output classes"""
import sys
import json
class I3BarOutput(object):
"""Manage output according to the i3bar protocol"""
def __init__(self):
pass
def start(self):
"""Print start preamble for i3bar protocol"""
sys.stdout.write(json.dumps({"version": 1, "click_events": True}) + "[\n")
def stop(self):
"""Finish i3bar protocol"""
sys.stdout.write("]\n")
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4