From f6b151945f50a3de1656031b60ef2410402bc3c0 Mon Sep 17 00:00:00 2001 From: Andreas Grapentin Date: Tue, 1 Mar 2022 18:40:35 +0100 Subject: [PATCH] refactoring output_format config query into setup --- py3status/core.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/py3status/core.py b/py3status/core.py index dbdd2d9f0b..3b484acf41 100644 --- a/py3status/core.py +++ b/py3status/core.py @@ -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, @@ -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]" @@ -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") @@ -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: