diff options
Diffstat (limited to '.config/fastfetch/confgen.py')
| -rw-r--r-- | .config/fastfetch/confgen.py | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/.config/fastfetch/confgen.py b/.config/fastfetch/confgen.py index d4983b5..22c53bc 100644 --- a/.config/fastfetch/confgen.py +++ b/.config/fastfetch/confgen.py | |||
| @@ -74,6 +74,13 @@ class Node: | |||
| 74 | self.children += nodes | 74 | self.children += nodes |
| 75 | return self | 75 | return self |
| 76 | 76 | ||
| 77 | def remove_module(self, module): | ||
| 78 | for i, node in enumerate(self.children): | ||
| 79 | if node.module == module: | ||
| 80 | del self.children[i] | ||
| 81 | return | ||
| 82 | node.remove_module(module) | ||
| 83 | |||
| 77 | 84 | ||
| 78 | schema = { | 85 | schema = { |
| 79 | "$schema": "https://github.com/fastfetch-cli/fastfetch/raw/dev/doc/json_schema.json" | 86 | "$schema": "https://github.com/fastfetch-cli/fastfetch/raw/dev/doc/json_schema.json" |
| @@ -194,7 +201,7 @@ roots = [ | |||
| 194 | modules["uptime"], | 201 | modules["uptime"], |
| 195 | modules["os_age"], | 202 | modules["os_age"], |
| 196 | modules["version"], | 203 | modules["version"], |
| 197 | ), | 204 | ) |
| 198 | ] | 205 | ] |
| 199 | 206 | ||
| 200 | modules = {"modules": list(flatten(root.collect_branch() for root in roots))} | 207 | modules = {"modules": list(flatten(root.collect_branch() for root in roots))} |
| @@ -210,5 +217,12 @@ with NamedTemporaryFile(mode='w', delete_on_close=False, suffix=".jsonc") as tmp | |||
| 210 | 217 | ||
| 211 | fastfetch_data = json.loads(fastfetch_response.stdout) | 218 | fastfetch_data = json.loads(fastfetch_response.stdout) |
| 212 | 219 | ||
| 213 | print(json.dumps(fastfetch_data, indent=2)) | 220 | skip_modules = ["Custom"] |
| 221 | for response_object in fastfetch_data: | ||
| 222 | if response_object.get("error") and response_object.get("type") not in skip_modules or response_object.get("result") == []: | ||
| 223 | for root in roots: | ||
| 224 | root.remove_module(response_object.get("type").lower()) | ||
| 225 | |||
| 226 | modules = {"modules": list(flatten(root.collect_branch() for root in roots))} | ||
| 214 | 227 | ||
| 228 | print(json.dumps(modules)) | ||
