From 003c28548cbd867f45cc5ac7d94b97fcd5706fe3 Mon Sep 17 00:00:00 2001 From: Cyril Levis Date: Sun, 8 Jul 2018 15:38:33 +0200 Subject: [PATCH] wip --- py3status/core.py | 33 +++++++++++++++++++-------------- py3status/module.py | 6 ++++-- 2 files changed, 23 insertions(+), 16 deletions(-) diff --git a/py3status/core.py b/py3status/core.py index a66b6ecd8a..04929b9387 100644 --- a/py3status/core.py +++ b/py3status/core.py @@ -950,21 +950,26 @@ def process_module_output(self, module): if 'color' not in output: output['color'] = color - if 'short_text' not in output: - if not short_format and output['full_text']: + if 'short_text' not in output and short_format: + if 'full_text' in output: full_text = output['full_text'] - if max_size and int(max_size) >= 1: - short = full_text[:max_size] if len(full_text) > int(max_size) else full_text - short = short + '..' if len(short + '..') < len(full_text) else short - output['short_text'] = short - elif max_size and isinstance(max_size, str): - size = int((len(full_text) + 1) / 2) - short = full_text[:size] - short = short + '..' if len(short + '..') < len(full_text) else short - output['short_text'] = short - - # Create the json string output. - return ','.join([dumps(x) for x in outputs]) + if max_size: + if isinstance(max_size, bool): + max_size = int((len(full_text) + 1) / 2) + self.log(max_size) + short = full_text[:int(max_size)] + self.log(short) + short = short + '..' if len(short + '..') < len(full_text) else short + self.log(short) + output['short_text'] = short + elif isinstance(max_size, int): + short = full_text[:max_size] if len(full_text) > int(max_size) else full_text + short = short + '..' if len(short + '..') < len(full_text) else short + output['short_text'] = short + + ret = ','.join([dumps(x) for x in outputs]) + self.log(ret) + return ret def i3bar_stop(self, signum, frame): self.i3bar_running = False diff --git a/py3status/module.py b/py3status/module.py index dc64363f9d..76c6265148 100644 --- a/py3status/module.py +++ b/py3status/module.py @@ -194,6 +194,7 @@ def error_output(self, message, method_affected=None): error = { 'full_text': message, + 'short_text': message, 'color': color, 'instance': self.module_inst, 'name': self.module_name, @@ -282,7 +283,7 @@ def set_updated(self): output.extend(data) else: # if the output is not 'valid' then don't add it. - if data.get('full_text') or 'separator' in data: + if data.get('full_text') or data.get('short_text') or 'separator' in data: if self.testing: data['cached_until'] = method.get('cached_until') output.append(data) @@ -688,7 +689,8 @@ def deprecation_log(item): 'instance': None, 'last_output': { 'name': method, - 'full_text': '' + 'full_text': '', + 'short_text': '' }, 'method': method, 'name': None