From 705c18dbcdcca6d08a2923dcde0d9b2813b42ba7 Mon Sep 17 00:00:00 2001 From: WORD559 Date: Sun, 6 May 2018 09:31:46 +0100 Subject: [PATCH] Can force status bar to update early by sending a USR1 signal to the process --- bumblebee-status | 5 +++++ bumblebee/engine.py | 27 +++++++++++++++------------ 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/bumblebee-status b/bumblebee-status index 2616094..9e8faa3 100755 --- a/bumblebee-status +++ b/bumblebee-status @@ -3,6 +3,7 @@ import os import sys import logging +import signal import bumblebee.theme import bumblebee.engine import bumblebee.config @@ -18,6 +19,9 @@ except Exception: def main(): + def sig_USR1_handler(signum,stack): + engine.write_output() + config = bumblebee.config.Config(sys.argv[1:]) if config.debug(): @@ -45,6 +49,7 @@ def main(): output=output, inp=inp, ) + signal.signal(10,sig_USR1_handler) engine.run() except KeyboardInterrupt as error: inp.stop() diff --git a/bumblebee/engine.py b/bumblebee/engine.py index a746db2..cdd4383 100644 --- a/bumblebee/engine.py +++ b/bumblebee/engine.py @@ -255,22 +255,25 @@ class Engine(object): """Start the event loop""" self._output.start() while self.running(): - self._output.begin() - for module in self._modules: - self._current_module = module - module.update_wrapper(module.widgets()) - if module.error == None: - 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() - self._output.end() + self.write_output() if self.running(): self.input.wait(float(self._config.get("interval", 1))) self._output.stop() self.input.stop() + def write_output(self): + self._output.begin() + for module in self._modules: + self._current_module = module + module.update_wrapper(module.widgets()) + if module.error == None: + 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() + self._output.end() + # vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4