diff --git a/bumblebee-status b/bumblebee-status index 9e8faa3..609f33b 100755 --- a/bumblebee-status +++ b/bumblebee-status @@ -48,6 +48,7 @@ def main(): config=config, output=output, inp=inp, + theme=theme, ) signal.signal(10,sig_USR1_handler) engine.run() diff --git a/bumblebee/engine.py b/bumblebee/engine.py index cdd4383..e940039 100644 --- a/bumblebee/engine.py +++ b/bumblebee/engine.py @@ -41,6 +41,9 @@ class Module(object): self.error = None self._next = int(time.time()) self._default_interval = 0 + self._minimized = False + + self._minimizedWidget = bumblebee.output.Widget(full_text=u"\u2026") self._configFile = None for cfg in [os.path.expanduser("~/.bumblebee-status.conf"), os.path.expanduser("~/.config/bumblebee-status.conf")]: @@ -56,6 +59,12 @@ class Module(object): if widgets: self._widgets = widgets if isinstance(widgets, list) else [widgets] + def toggle_minimize(self): + self._minimized = not self._minimized + + def minimized(self): + return self._minimized + def widgets(self): """Return the widgets to draw for this module""" return self._widgets @@ -68,6 +77,9 @@ class Module(object): if widget.name == name: return widget + def minimizedWidget(self): + return self._minimizedWidget + def errorWidget(self): msg = self.error if len(msg) > 10: @@ -78,6 +90,8 @@ class Module(object): for widget in self._widgets: if widget.id == uid: return widget + if self._minimizedWidget.id == uid: + return self._minimizedWidget return None def update(self, widgets): @@ -110,12 +124,9 @@ class Module(object): """Return the config parameter 'name' for this module""" name = "{}.{}".format(self.name, name) value = self._config["config"].get(name, default) - log.debug("command line parameter {}={}".format(name, str(value))) if value == default: try: - log.debug("trying to read {} from configuration file".format(name)) value = self._configFile.get("module-parameters", name) - log.debug("configuration file {}={}".format(name, str(value))) except: pass return value @@ -133,7 +144,7 @@ class Engine(object): This class connects input/output, instantiates all required modules and drives the "event loop" """ - def __init__(self, config, output=None, inp=None): + def __init__(self, config, output=None, inp=None, theme=None): self._output = output self._config = config self._running = True @@ -142,6 +153,7 @@ class Engine(object): self._aliases = self._read_aliases() self.load_modules(config.modules()) self._current_module = None + self._theme = theme if bumblebee.util.asbool(config.get("engine.workspacewheel", "true")): if bumblebee.util.asbool(config.get("engine.workspacewrap", "true")): @@ -154,9 +166,18 @@ class Engine(object): cmd=self._prev_workspace) self.input.register_callback(None, bumblebee.input.WHEEL_DOWN, cmd=self._next_workspace) + if bumblebee.util.asbool(config.get("engine.collapsible", "true")): + self.input.register_callback(None, bumblebee.input.MIDDLE_MOUSE, + cmd=self._toggle_minimize) self.input.start() + def _toggle_minimize(self, event): + for module in self._modules: + if module.widget_by_id(event["instance"]): + log.debug("module {} found - toggle minimize".format(module.id)) + module.toggle_minimize() + def _prev_workspace(self, event): self._change_workspace(-1) @@ -268,9 +289,16 @@ class Engine(object): self._current_module = module module.update_wrapper(module.widgets()) if module.error == None: - for widget in module.widgets(): + if module.minimized(): + widget = module.minimizedWidget() widget.link_module(module) + if self._theme: + icon = self._theme.icon(widget) self._output.draw(widget=widget, module=module, engine=self) + else: + for widget in module.widgets(): + widget.link_module(module) + self._output.draw(widget=widget, module=module, engine=self) else: self._output.draw(widget=module.errorWidget(), module=module, engine=self) self._output.flush() diff --git a/bumblebee/output.py b/bumblebee/output.py index 99dadc3..79efb49 100644 --- a/bumblebee/output.py +++ b/bumblebee/output.py @@ -102,10 +102,12 @@ class I3BarOutput(object): padding = self._theme.padding(widget) prefix = self._theme.prefix(widget, padding) suffix = self._theme.suffix(widget, padding) + if prefix: full_text = u"{}{}".format(prefix, full_text) if suffix: full_text = u"{}{}".format(full_text, suffix) + separator = self._theme.separator(widget) if separator: self._widgets.append({ diff --git a/bumblebee/theme.py b/bumblebee/theme.py index 891094d..a75bada 100644 --- a/bumblebee/theme.py +++ b/bumblebee/theme.py @@ -100,6 +100,11 @@ class Theme(object): self._widget = None self._prevbg = None + def icon(self, widget): + icon = self._get(widget, "icon", None) + if icon == None: + return self._get(widget, "prefix", None) + def padding(self, widget): """Return padding for widget""" return self._get(widget, "padding", "")