From 07ca5cf383c027f2a0a7a4020c690a8cdade721b Mon Sep 17 00:00:00 2001 From: tobi-wan-kenobi Date: Sun, 12 Apr 2020 14:44:02 +0200 Subject: [PATCH] [core/output] Make it possible to update modules via events Add an event callback "update-modules" that allows various pieces of bumblebee-status to update the status bar. --- core/output.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/core/output.py b/core/output.py index 4b14844..3f8cff5 100644 --- a/core/output.py +++ b/core/output.py @@ -105,6 +105,7 @@ class i3(object): self.__content = {} self.__theme = theme self.__config = config + core.event.register('update-modules', self.update) core.event.register('start', self.draw, 'start') core.event.register('update', self.draw, 'statusline') core.event.register('stop', self.draw, 'stop') @@ -165,7 +166,7 @@ class i3(object): return blocks # TODO: only updates full text, not the state!? - def update(self, affected_modules=None): + def update(self, affected_modules=None, redraw_only=False): now = time.time() for module in self.__modules: if affected_modules and not module.id in affected_modules: @@ -173,8 +174,9 @@ class i3(object): if not affected_modules and module.next_update: if now < module.next_update: continue - module.update_wrapper() - module.next_update = now + float(module.parameter('interval', self.__config.interval())) + if not redraw_only: + module.update_wrapper() + module.next_update = now + float(module.parameter('interval', self.__config.interval())) for widget in module.widgets(): self.__content[widget] = widget.full_text()