bumblebee-status/bumblebee/outputs/i3.py
Tobias Witek 3ca53dd0fa [themes] Make individual items theme-able (a bit)
Individual items in the bar can now be configured with a prefix and a
suffix. It works like this:

* If there is a specific module configuration in the theme
  configuration, use that (i.e. { "<modulename>": { "prefix: " a " } })
* Otherwise, if there is a configuration in the "default" section of the
  theme, use that
* Otherwise, if the module object itself has a method called like the
  required attribute (prefix, suffix), use that
* Otherwise, leave prefix/suffix empty ("")
2016-10-31 07:18:57 +01:00

27 lines
650 B
Python

import json
import bumblebee.output
class i3bar(bumblebee.output.Output):
def __init__(self):
self._data = []
def start(self):
return json.dumps({ "version": 1 }) + "["
def add(self, obj):
theme = obj.theme()
self._data.append({
"full_text": "%s%s%s" % (theme.prefix(obj), obj.data(), theme.suffix(obj)),
"separator": False,
"separator_block_width": 0,
})
def get(self):
data = json.dumps(self._data)
self._data = []
return data + ","
def stop(self):
return "]"
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4