Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

core: add short_text support [wip] #1494

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 15 additions & 12 deletions py3status/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -904,18 +904,18 @@ def create_output_modules(self):
for name in self.modules:
if name not in output_modules:
output_modules[name] = {}
output_modules[name]["position"] = positions.get(name, [])
output_modules[name]["module"] = self.modules[name]
output_modules[name]["type"] = "py3status"
output_modules[name]["color"] = self.mappings_color.get(name)
output_modules[name]['position'] = positions.get(name, [])
output_modules[name]['module'] = self.modules[name]
output_modules[name]['type'] = 'py3status'
output_modules[name]['color'] = self.mappings_color.get(name)
# i3status modules
for name in i3modules:
if name not in output_modules:
output_modules[name] = {}
output_modules[name]["position"] = positions.get(name, [])
output_modules[name]["module"] = i3modules[name]
output_modules[name]["type"] = "i3status"
output_modules[name]["color"] = self.mappings_color.get(name)
output_modules[name]['position'] = positions.get(name, [])
output_modules[name]['module'] = i3modules[name]
output_modules[name]['type'] = 'i3status'
output_modules[name]['color'] = self.mappings_color.get(name)

self.output_modules = output_modules

Expand All @@ -932,6 +932,7 @@ def create_mappings(self, config):
if hasattr(color, "none_setting"):
color = None
mappings[name] = color

# Store mappings for later use.
self.mappings_color = mappings

Expand All @@ -940,13 +941,15 @@ def process_module_output(self, module):
Process the output for a module and return a json string representing it.
Color processing occurs here.
"""
outputs = module["module"].get_latest()
color = module["color"]
if color:
for output in outputs:
outputs = module['module'].get_latest()
color = module['color']

for output in outputs:
if color:
# Color: substitute the config defined color
if "color" not in output:
output["color"] = color

# Create the json string output.
return ",".join([dumps(x) for x in outputs])

Expand Down
36 changes: 23 additions & 13 deletions py3status/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,10 +190,11 @@ def error_output(self, message, method_affected=None):
color = None

error = {
"full_text": message,
"color": color,
"instance": self.module_inst,
"name": self.module_name,
'full_text': message,
'short_text': message,
'color': color,
'instance': self.module_inst,
'name': self.module_name,
}
for method in self.methods.values():
if method_affected and method["method"] != method_affected:
Expand Down Expand Up @@ -279,7 +280,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 @@ -650,15 +651,20 @@ def deprecation_log(item):
if not hasattr(self.module_class, "py3"):
setattr(self.module_class, "py3", Py3(self))

# allow_urgent
# get the value form the config or use the module default if
# get the value from the config or use the module default if
# supplied.
fn = self._py3_wrapper.get_config_attribute
param = fn(self.module_full_name, "allow_urgent")
if hasattr(param, "none_setting"):
param = True
self.allow_urgent = param

# max_size
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 All @@ -677,12 +683,16 @@ def deprecation_log(item):
# the method_obj stores infos about each method
# of this module.
method_obj = {
"cached_until": time(),
"call_type": params_type,
"instance": None,
"last_output": {"name": method, "full_text": ""},
"method": method,
"name": None,
'cached_until': time(),
'call_type': params_type,
'instance': None,
'last_output': {
'name': method,
'full_text': '',
'short_text': ''
},
'method': method,
'name': None
}
self.methods[method] = method_obj

Expand Down
3 changes: 2 additions & 1 deletion py3status/modules/wwan.py
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,8 @@ def wwan(self):

response = {
'cached_until': self.py3.time_in(self.cache_timeout),
'full_text': self.py3.safe_format(self.format, wwan_data)
'full_text': self.py3.safe_format(self.format, wwan_data),
'short_text': self.py3.safe_format(self.short_format, wwan_data)
}
if urgent:
response['urgent'] = True
Expand Down