diff --git a/bumblebee-status b/bumblebee-status index 609f33b..bb31f94 100755 --- a/bumblebee-status +++ b/bumblebee-status @@ -39,7 +39,7 @@ def main(): ) theme = bumblebee.theme.Theme(config.theme(), config.iconset()) - output = bumblebee.output.I3BarOutput(theme=theme) + output = bumblebee.output.I3BarOutput(theme=theme, config=config) inp = bumblebee.input.I3BarInput() engine = None diff --git a/bumblebee/config.py b/bumblebee/config.py index a70fe6b..9f6384a 100644 --- a/bumblebee/config.py +++ b/bumblebee/config.py @@ -57,6 +57,8 @@ def create_parser(): help=LIST_HELP) parser.add_argument("-d", "--debug", action="store_true", help=DEBUG_HELP) + parser.add_argument("-r", "--right-to-left", action="store_true", + help="Draw widgets from right to left, rather than left to right (which is the default)") parser.add_argument("-f", "--logfile", default="~/bumblebee-status-debug.log", help="Location of the debug log file") parser.add_argument("-i", "--iconset", default="auto", @@ -100,6 +102,9 @@ class Config(bumblebee.store.Store): def debug(self): return self._args.debug + def reverse(self): + return self._args.right_to_left + def logfile(self): return os.path.expanduser(self._args.logfile) diff --git a/bumblebee/output.py b/bumblebee/output.py index 2569fae..a8a25d4 100644 --- a/bumblebee/output.py +++ b/bumblebee/output.py @@ -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"""