Skip to content

Commit

Permalink
refactoring output_format config query into setup
Browse files Browse the repository at this point in the history
  • Loading branch information
oaken-source committed Mar 3, 2022
1 parent f42605e commit 6d12ba6
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions py3status/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -677,6 +677,10 @@ def setup(self):
# load and spawn i3status.conf configured modules threads
self.load_modules(self.py3_modules, user_modules)

self.output_format = self.config["py3_config"]["general"].get(
"output_format", "i3bar"
)

def notify_user(
self,
msg,
Expand Down Expand Up @@ -971,7 +975,7 @@ def process_module_output(self, module):
if "color" not in output:
output["color"] = color
# Create the tmux string output.
if self.config["py3_config"]["general"].get("output_format") == "tmux":
if self.output_format == "tmux":
for output in outputs:
if "color" in output:
tmux_full_text = f"#[fg={output['color'].lower()}]{output['full_text']}#[default]"
Expand Down Expand Up @@ -1049,7 +1053,7 @@ def run(self):
"click_events": self.config["click_events"],
"stop_signal": self.stop_signal or 0,
}
if self.config["py3_config"]["general"].get("output_format") != "tmux":
if self.output_format != "tmux":
write(dumps(header))
write("\n[[]\n")

Expand Down Expand Up @@ -1080,7 +1084,7 @@ def run(self):

# build output string and dump to stdout
out = ""
if self.config["py3_config"]["general"].get("output_format") == "tmux":
if self.output_format == "tmux":
out = "#[fg=brightblack]|#[default]".join(x for x in output if x)
write(f"{out}\n")
else:
Expand Down

0 comments on commit 6d12ba6

Please sign in to comment.