From c4683f3700aed3f28bb390347094e5b1c429efcc Mon Sep 17 00:00:00 2001 From: Tobias Witek Date: Sun, 30 Oct 2016 15:58:35 +0100 Subject: [PATCH] [output] Create preliminary framework for output handling Prepare a framework for having modular outputs. Essentially, the main application uses a output-type object to format strings for the preamble, the actual data items, and a "postamble" (finalizer). The printing of that representation, again, is up to the main application, not the output framework. Probably, at some point in the future, an interface class will be in order, but right now, I want to keep it lean - seeing as for the forseeable future, i3bar is going to be the one and only consumer of this. --- bumblebee/__init__.py | 0 bumblebee/outputs/__init__.py | 0 bumblebee/outputs/i3.py | 13 +++++++++++++ i3bumblebee | 20 ++++++++++++++++++++ 4 files changed, 33 insertions(+) create mode 100644 bumblebee/__init__.py create mode 100644 bumblebee/outputs/__init__.py create mode 100644 bumblebee/outputs/i3.py create mode 100755 i3bumblebee diff --git a/bumblebee/__init__.py b/bumblebee/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/bumblebee/outputs/__init__.py b/bumblebee/outputs/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/bumblebee/outputs/i3.py b/bumblebee/outputs/i3.py new file mode 100644 index 0000000..39c8e20 --- /dev/null +++ b/bumblebee/outputs/i3.py @@ -0,0 +1,13 @@ +import json + +class i3bar: + def preamble(self): + return json.dumps({ "version": 1 }) + "[" + + def data(self, data): + return json.dumps(data) + "," + + def finalize(self): + return "]" + +# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4 diff --git a/i3bumblebee b/i3bumblebee new file mode 100755 index 0000000..f798013 --- /dev/null +++ b/i3bumblebee @@ -0,0 +1,20 @@ +#!/usr/bin/env python + +import bumblebee.outputs.i3 + +def main(): + output = bumblebee.outputs.i3.i3bar() + + print output.preamble() + + while True: + # TODO: retrieve data from modules + data = [] + print output.data(data) + + print output.finalize() + +if __name__ == "__main__": + main() + +# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4