From 8083a35e0f2881e6b232742550852675838d8a5a Mon Sep 17 00:00:00 2001 From: Cyril Levis Date: Thu, 5 Jul 2018 23:43:23 +0200 Subject: [PATCH] handle i3status 'short_text'. simple way to transform with settings a 'max_size' globally for all module or per module. short_text is used if returned text size is larger than monitor. --- py3status/core.py | 8 ++++++++ py3status/module.py | 9 +++++++++ 2 files changed, 17 insertions(+) diff --git a/py3status/core.py b/py3status/core.py index f5761c8481..193fd7d32f 100644 --- a/py3status/core.py +++ b/py3status/core.py @@ -932,13 +932,21 @@ def create_mappings(self, config): if hasattr(color, "none_setting"): color = None mappings[name] = color + + max_size = self.get_config_attribute(name, 'max_size') + if hasattr(max_size, 'none_setting'): + max_size = None + mappings[name] = max_size + # Store mappings for later use. + self.mappings_max_size = mappings self.mappings_color = mappings def process_module_output(self, module): """ Process the output for a module and return a json string representing it. Color processing occurs here. + Shortened text 'short_text' processing occurs here. """ outputs = module["module"].get_latest() color = module["color"] diff --git a/py3status/module.py b/py3status/module.py index 74a869a9e8..39e313bb47 100644 --- a/py3status/module.py +++ b/py3status/module.py @@ -659,6 +659,15 @@ def deprecation_log(item): param = True self.allow_urgent = param + # max_size + # get the value form the config or use the module default if + # supplied. + fn = self._py3_wrapper.get_config_attribute + param = fn(self.module_full_name, 'max_size') + if hasattr(param, 'none_setting'): + param = True + self.max_size = param + # get the available methods for execution for method in sorted(dir(class_inst)): if method.startswith("_"):