Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
cyrinux committed Sep 3, 2018
1 parent 1cebe08 commit 003c285
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 16 deletions.
33 changes: 19 additions & 14 deletions py3status/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 4 additions & 2 deletions py3status/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -688,7 +689,8 @@ def deprecation_log(item):
'instance': None,
'last_output': {
'name': method,
'full_text': ''
'full_text': '',
'short_text': ''
},
'method': method,
'name': None
Expand Down

0 comments on commit 003c285

Please sign in to comment.