From 12856fb677df10b11032e5e84b871a50ee14e16a Mon Sep 17 00:00:00 2001 From: Pavel Egorov Date: Tue, 16 Dec 2025 13:58:37 +0300 Subject: [fastfetch] remove nodes with empty data --- .config/fastfetch/confgen.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to '.config/fastfetch') 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: self.children += nodes return self + def remove_module(self, module): + for i, node in enumerate(self.children): + if node.module == module: + del self.children[i] + return + node.remove_module(module) + schema = { "$schema": "https://github.com/fastfetch-cli/fastfetch/raw/dev/doc/json_schema.json" @@ -194,7 +201,7 @@ roots = [ modules["uptime"], modules["os_age"], modules["version"], - ), + ) ] 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 fastfetch_data = json.loads(fastfetch_response.stdout) -print(json.dumps(fastfetch_data, indent=2)) +skip_modules = ["Custom"] +for response_object in fastfetch_data: + if response_object.get("error") and response_object.get("type") not in skip_modules or response_object.get("result") == []: + for root in roots: + root.remove_module(response_object.get("type").lower()) + +modules = {"modules": list(flatten(root.collect_branch() for root in roots))} +print(json.dumps(modules)) -- cgit v1.3