diff options
| author | Pavel Egorov <[email protected]> | 2025-12-19 04:08:46 +0300 |
|---|---|---|
| committer | Pavel Egorov <[email protected]> | 2025-12-19 04:08:46 +0300 |
| commit | 9e037c2b066eae68c0df6cc2885ed2e2e6a45af8 (patch) | |
| tree | 0f916066f97f5100f512008e0c6ac53fd95b5e79 /.config | |
| parent | 989c2857d4da3fa163dc77289b67cbd2eeb59d26 (diff) | |
| download | dotfiles-9e037c2b066eae68c0df6cc2885ed2e2e6a45af8.tar.gz dotfiles-9e037c2b066eae68c0df6cc2885ed2e2e6a45af8.zip | |
[fastfetch] make configs pretty
Diffstat (limited to '.config')
| -rw-r--r-- | .config/fastfetch/confgen.py | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/.config/fastfetch/confgen.py b/.config/fastfetch/confgen.py index 3925140..aa64f6a 100644 --- a/.config/fastfetch/confgen.py +++ b/.config/fastfetch/confgen.py | |||
| @@ -4,6 +4,7 @@ from typing import Optional, Any, Iterator | |||
| 4 | import json | 4 | import json |
| 5 | from tempfile import NamedTemporaryFile | 5 | from tempfile import NamedTemporaryFile |
| 6 | import subprocess | 6 | import subprocess |
| 7 | from pathlib import Path | ||
| 7 | 8 | ||
| 8 | 9 | ||
| 9 | def flatten(obj) -> Iterator[Any]: | 10 | def flatten(obj) -> Iterator[Any]: |
| @@ -62,17 +63,28 @@ class Node: | |||
| 62 | return | 63 | return |
| 63 | node.remove_module(module) | 64 | node.remove_module(module) |
| 64 | 65 | ||
| 65 | def prettify(self, font_effect=None, key_prefix="") -> None: | 66 | def prettify(self, font_effect="", key_prefix="") -> None: |
| 66 | if key_prefix: | ||
| 67 | self.key = key_prefix + f'{graphics["hbar"]} ' + self.key | ||
| 68 | if self.font_effect: | 67 | if self.font_effect: |
| 69 | font_effect = self.font_effect | 68 | font_effect = self.font_effect |
| 69 | self.key = font_effect + self.key | ||
| 70 | |||
| 71 | if len(key_prefix): | ||
| 72 | self.key = key_prefix + f'{graphics["hbar"]} ' + self.key | ||
| 73 | |||
| 74 | if key_prefix[-1] == graphics["end"]: | ||
| 75 | key_prefix = key_prefix[:-1] + ' ' | ||
| 76 | else: | ||
| 77 | key_prefix = key_prefix[:-1] + graphics["vbar"] + ' ' | ||
| 78 | |||
| 70 | for i, node in enumerate(self.children): | 79 | for i, node in enumerate(self.children): |
| 71 | node.prettify(font_effect, key_prefix) | 80 | if i == len(self.children) - 1: |
| 81 | node.prettify(font_effect, key_prefix + font_effect + graphics["end"]) | ||
| 82 | else: | ||
| 83 | node.prettify(font_effect, key_prefix + font_effect + graphics["branch"]) | ||
| 72 | 84 | ||
| 73 | 85 | ||
| 74 | font_effects = { | 86 | font_effects = { |
| 75 | "reset": "#0", | 87 | "reset": "{#0}", |
| 76 | "software": "\u001b[38;2;0;255;0m", | 88 | "software": "\u001b[38;2;0;255;0m", |
| 77 | "os": "\u001b[38;2;0;255;60m", | 89 | "os": "\u001b[38;2;0;255;60m", |
| 78 | "terminal": "\u001b[38;2;0;255;120m", | 90 | "terminal": "\u001b[38;2;0;255;120m", |
| @@ -229,7 +241,9 @@ def main(): | |||
| 229 | for root in filtered_roots: | 241 | for root in filtered_roots: |
| 230 | root.prettify() | 242 | root.prettify() |
| 231 | final_config = build_config(filtered_roots) | 243 | final_config = build_config(filtered_roots) |
| 232 | print(json.dumps(final_config)) | 244 | fastfetch_config = Path.home() / ".config" / "fastfetch" / "config_generated.jsonc" |
| 245 | with open(fastfetch_config, 'w') as config_file: | ||
| 246 | json.dump(final_config, config_file) | ||
| 233 | 247 | ||
| 234 | 248 | ||
| 235 | if __name__ == '__main__': | 249 | if __name__ == '__main__': |
