[core] Add option to draw widgets right-to-left

fixes #295
This commit is contained in:
Tobias Witek 2018-09-22 14:40:32 +02:00
parent 8863ce1c5b
commit e80ae8b91e
3 changed files with 12 additions and 3 deletions

View file

@ -83,10 +83,11 @@ class Widget(bumblebee.store.Store):
class I3BarOutput(object):
"""Manage output according to the i3bar protocol"""
def __init__(self, theme):
def __init__(self, theme, config=None):
self._theme = theme
self._widgets = []
self._started = False
self._config = config
def started(self):
return self._started
@ -143,7 +144,10 @@ class I3BarOutput(object):
def flush(self):
"""Flushes output"""
sys.stdout.write(json.dumps(self._widgets))
widgets = self._widgets
if self._config and self._config.reverse():
widgets = list(reversed(widgets))
sys.stdout.write(json.dumps(widgets))
def end(self):
"""Finalizes output"""