Skip to content

Commit

Permalink
handle i3status 'short_text'.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
cyrinux committed Oct 2, 2018
1 parent 6c24530 commit 8083a35
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
8 changes: 8 additions & 0 deletions py3status/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
9 changes: 9 additions & 0 deletions py3status/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -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("_"):
Expand Down

0 comments on commit 8083a35

Please sign in to comment.