From 9c201421517b485f9c81bbd167a73f77352be4e6 Mon Sep 17 00:00:00 2001 From: Pavel Egorov Date: Tue, 16 Dec 2025 13:40:05 +0300 Subject: [fastfetch] dump config and run fastfetch on it --- .config/fastfetch/confgen.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to '.config') diff --git a/.config/fastfetch/confgen.py b/.config/fastfetch/confgen.py index de1bda5..d4983b5 100644 --- a/.config/fastfetch/confgen.py +++ b/.config/fastfetch/confgen.py @@ -1,6 +1,9 @@ #!/usr/bin/env python3 from typing import Optional, Any, Iterator +import json +from tempfile import NamedTemporaryFile +import subprocess def flatten(obj) -> Iterator[Any]: @@ -182,6 +185,7 @@ roots = [ modules["gpu"].add_children(modules["gpu_driver"]), modules["disk"], modules["ram"].add_children(modules["swap"]), + modules["battery"], ), modules["display"] ), @@ -193,5 +197,18 @@ roots = [ ), ] +modules = {"modules": list(flatten(root.collect_branch() for root in roots))} + +with NamedTemporaryFile(mode='w', delete_on_close=False, suffix=".jsonc") as tmp_config: + json.dump(schema | logo | modules, tmp_config) + tmp_config.flush() + + fastfetch_response = subprocess.run( + ["fastfetch", "--config", tmp_config.name, "--json"], + capture_output=True + ) + +fastfetch_data = json.loads(fastfetch_response.stdout) + +print(json.dumps(fastfetch_data, indent=2)) -modules = [flatten(root.collect_branch()) for root in roots] -- cgit v1.3