From a919d2e7f072cf7abf397d3039f0befc8853298f Mon Sep 17 00:00:00 2001 From: Ivan Chinenov Date: Sat, 30 Nov 2019 14:56:40 +0300 Subject: [PATCH 1/2] Added 'show_freq' option to sensors module --- bumblebee/modules/sensors.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/bumblebee/modules/sensors.py b/bumblebee/modules/sensors.py index 567d9db..8ad86a3 100644 --- a/bumblebee/modules/sensors.py +++ b/bumblebee/modules/sensors.py @@ -11,7 +11,7 @@ Parameters: * sensors.match: (fallback) Line to match against output of 'sensors -u' (default: temp1_input) * sensors.match_pattern: (fallback) Line to match against before temperature is read (no default) * sensors.match_number: (fallback) which of the matches you want (default -1: last match). - + * sensors.show_freq: whether to show CPU frequency. (default: true) """ import re @@ -35,6 +35,7 @@ class Module(bumblebee.engine.Module): self._match_pattern = self.parameter("match_pattern", None) self._pattern = re.compile(r"^\s*{}:\s*([\d.]+)$".format(self.parameter("match", "temp1_input")), re.MULTILINE) self._json = bumblebee.util.asbool(self.parameter("json", "false")) + self._freq = bumblebee.util.asbool(self.parameter("show_freq", "true")) engine.input.register_callback(self, button=bumblebee.input.LEFT_MOUSE, cmd="xsensors") self.determine_method() @@ -115,10 +116,13 @@ class Module(bumblebee.engine.Module): return "{:0.01f} GHz".format(float(mhz)/1000.0) def temperature(self, _): - return u"{}°c @ {}".format(self._temperature, self._mhz) - + if self._freq: + return u"{}°c @ {}".format(self._temperature, self._mhz) + else: + return u"{}°c".format(self._temperature) def update(self, widgets): self._temperature = self.get_temp() - self._mhz = self.get_mhz() + if self._freq: + self._mhz = self.get_mhz() # vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4 From 9d7fdfa1a30107d4bcf06aef1f44cb15e80cfb1b Mon Sep 17 00:00:00 2001 From: Tobias Witek Date: Sat, 30 Nov 2019 13:52:27 +0100 Subject: [PATCH 2/2] [core] Allow fallback of config parameters Some modules (such as pulseaudio) have aliases (pasink, pasource), which mean that the module's name might differ from it's "parent" name. To make it possible to have shared config parameters, add a fallback that reads the "module" parameter, if no instance parameter is found. fixes #467 --- bumblebee/engine.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/bumblebee/engine.py b/bumblebee/engine.py index 9315da5..1159884 100644 --- a/bumblebee/engine.py +++ b/bumblebee/engine.py @@ -118,8 +118,10 @@ class Module(object): def parameter(self, name, default=None): """Return the config parameter 'name' for this module""" + module_name = "{}.{}".format(self.__module__.split(".")[-1], name) name = "{}.{}".format(self.name, name) - value = self._config["config"].get(name, default) + value = self._config["config"].get(module_name, default) + value = self._config["config"].get(name, value) if value == default: try: value = self._configFile.get("module-parameters", name)