Skip to content

WIP: fix separator logic to be in line with i3status#2148

Closed
ultrabug wants to merge 1 commit into
masterfrom
separator
Closed

WIP: fix separator logic to be in line with i3status#2148
ultrabug wants to merge 1 commit into
masterfrom
separator

Conversation

@ultrabug

@ultrabug ultrabug commented Oct 2, 2022

Copy link
Copy Markdown
Owner

closes #2116

@lasers

lasers commented Oct 5, 2022

Copy link
Copy Markdown
Contributor

Months ago, I made a small diff that makes py3status to be in more line with i3status too (just for the terminal)... made after #2104.

commit d2ef7e4f3b35df093bb7b6c41b53d516e88a9a23
Author: lasers <lasers@lasers.com>
Date:   Tue Apr 5 03:41:33 2022 -0500

    core: autodetect output_format

diff --git a/py3status/constants.py b/py3status/constants.py
index 2868625e..a0375ccd 100644
--- a/py3status/constants.py
+++ b/py3status/constants.py
@@ -7,7 +7,7 @@ GENERAL_DEFAULTS = {
     "color_separator": "#333333",
     "colors": True,
     "interval": 5,
-    "output_format": "i3bar",
+    "output_format": None,
 }
 
 MAX_NESTING_LEVELS = 4
diff --git a/py3status/core.py b/py3status/core.py
index 9adab8bf..98b9f022 100644
--- a/py3status/core.py
+++ b/py3status/core.py
@@ -568,6 +568,16 @@ class Py3statusWrapper:
         self.log("config file: {}".format(self.config["i3status_config_path"]))
         self.config["py3_config"] = process_config(config_path, self)
 
+        # autodetect output_format
+        output_format = self.config["py3_config"]["general"]["output_format"]
+        if output_format is None:
+            if sys.stdout.isatty():
+                print("py3status: trying to auto-detect output_format setting")
+                print('py3status: auto-detected "term"')
+                output_format = "term"
+
+        self.config["py3_config"]["general"]["output_format"] = output_format or "i3bar"
+
         # read resources
         if "resources" in str(self.config["py3_config"].values()):
             from subprocess import check_output

... then the next / this PR could be looked at to fix separator hack / issue... It would be ideal to support both (py3status) boolean + (i3status) string options... Maybe by converting False to "" and ignoring True. I haven't made anything for this hack / issue.

@lasers

lasers commented Jun 18, 2023

Copy link
Copy Markdown
Contributor

(Self note) Don't test i3status in terminal because i3status wasn't designed for that and doesn't honor separator = false config in the terminal, but will work fine on i3bar.

@ultrabug

Copy link
Copy Markdown
Owner Author

Either we rework it properly, or leave it as is

@ultrabug ultrabug closed this Jun 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

py3status doesn't parse separator

2 participants