Conversation
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 |
Contributor
|
(Self note) Don't test |
Owner
Author
|
Either we rework it properly, or leave it as is |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
closes #2116