summaryrefslogtreecommitdiffstats
path: root/.config/fastfetch
diff options
context:
space:
mode:
authorPavel Egorov <[email protected]>2025-12-16 13:58:37 +0300
committerPavel Egorov <[email protected]>2025-12-16 13:58:37 +0300
commit12856fb677df10b11032e5e84b871a50ee14e16a (patch)
tree8b0869411aec3d732f357976d2a13fcbf037fa9b /.config/fastfetch
parent9c201421517b485f9c81bbd167a73f77352be4e6 (diff)
downloaddotfiles-12856fb677df10b11032e5e84b871a50ee14e16a.tar.gz
dotfiles-12856fb677df10b11032e5e84b871a50ee14e16a.zip
[fastfetch] remove nodes with empty data
Diffstat (limited to '.config/fastfetch')
-rw-r--r--.config/fastfetch/confgen.py18
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
78schema = { 85schema = {
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
200modules = {"modules": list(flatten(root.collect_branch() for root in roots))} 207modules = {"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
211fastfetch_data = json.loads(fastfetch_response.stdout) 218fastfetch_data = json.loads(fastfetch_response.stdout)
212 219
213print(json.dumps(fastfetch_data, indent=2)) 220skip_modules = ["Custom"]
221for 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
226modules = {"modules": list(flatten(root.collect_branch() for root in roots))}
214 227
228print(json.dumps(modules))