From a84e568746edc645ce0b3748f780c7b736f7aa96 Mon Sep 17 00:00:00 2001 From: Camilo Celis Guzman Date: Wed, 25 Oct 2017 18:36:13 +0900 Subject: [PATCH 1/2] [modules/rotation] create a widget per display once on refresh * This module only updates some information on the screen when a new display is added/removed, hence it makes sense to update it only when the i3-bar is refreshed. --- bumblebee/modules/rotation.py | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/bumblebee/modules/rotation.py b/bumblebee/modules/rotation.py index b03123d..23552d0 100644 --- a/bumblebee/modules/rotation.py +++ b/bumblebee/modules/rotation.py @@ -21,7 +21,6 @@ class Module(bumblebee.engine.Module): self.update_widgets(widgets) def update_widgets(self, widgets): - new_widgets = [] for line in bumblebee.util.execute("xrandr -q").split("\n"): if not " connected" in line: continue @@ -37,16 +36,12 @@ class Module(bumblebee.engine.Module): if not widget: widget = bumblebee.output.Widget(full_text=display, name=display) self._engine.input.register_callback(widget, button=bumblebee.input.LEFT_MOUSE, cmd=self._toggle) - new_widgets.append(widget) widget.set("orientation", orientation) - - while len(widgets) > 0: - del widgets[0] - for widget in new_widgets: widgets.append(widget) def update(self, widgets): - self.update_widgets(widgets) + if len(widgets) <= 0: + self.update_widgets(widgets) def state(self, widget): return widget.get("orientation", "normal") From 28ee0b474d95589c1337799499829a23d98d9c13 Mon Sep 17 00:00:00 2001 From: Camilo Celis Guzman Date: Wed, 25 Oct 2017 18:36:53 +0900 Subject: [PATCH 2/2] added format parameter to cpu module --- bumblebee/modules/cpu.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/bumblebee/modules/cpu.py b/bumblebee/modules/cpu.py index 5f13401..ed5b856 100644 --- a/bumblebee/modules/cpu.py +++ b/bumblebee/modules/cpu.py @@ -5,6 +5,7 @@ Parameters: * cpu.warning : Warning threshold in % of CPU usage (defaults to 70%) * cpu.critical: Critical threshold in % of CPU usage (defaults to 80%) + * cpu.format : Format string (defaults to "{:.01f}%)") """ try: @@ -25,8 +26,12 @@ class Module(bumblebee.engine.Module): engine.input.register_callback(self, button=bumblebee.input.LEFT_MOUSE, cmd="gnome-system-monitor") + @property + def _format(self): + return self.parameter("format", "{:.01f}%") + def utilization(self, _): - return "{:.01f}%".format(self._utilization) + return self._format.format(self._utilization) def update(self, widgets): self._utilization = psutil.cpu_percent(percpu=False)