summaryrefslogtreecommitdiffstats
path: root/.config/fastfetch/confgen.py
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--.config/fastfetch/confgen.py21
1 files changed, 16 insertions, 5 deletions
diff --git a/.config/fastfetch/confgen.py b/.config/fastfetch/confgen.py
index e8b1383..c368582 100644
--- a/.config/fastfetch/confgen.py
+++ b/.config/fastfetch/confgen.py
@@ -199,7 +199,7 @@ roots = [
199] 199]
200 200
201 201
202def build_config(roots) -> dict[str, type[Any]]: 202def build_config(roots: list[Node]) -> dict[str, type[Any]]:
203 schema = { 203 schema = {
204 "$schema": "https://github.com/fastfetch-cli/fastfetch/raw/dev/doc/json_schema.json" 204 "$schema": "https://github.com/fastfetch-cli/fastfetch/raw/dev/doc/json_schema.json"
205 } 205 }
@@ -211,9 +211,9 @@ def build_config(roots) -> dict[str, type[Any]]:
211 return schema | logo | modules 211 return schema | logo | modules
212 212
213 213
214def get_test_response() -> list[dict]: 214def get_test_response(config: dict[str, type[Any]]) -> list[dict]:
215 with NamedTemporaryFile(mode='w', delete_on_close=False, suffix=".jsonc") as tmp_config: 215 with NamedTemporaryFile(mode='w', delete_on_close=False, suffix=".jsonc") as tmp_config:
216 json.dump(build_config(roots), tmp_config) 216 json.dump(config, tmp_config)
217 tmp_config.flush() 217 tmp_config.flush()
218 218
219 fastfetch_response = subprocess.run( 219 fastfetch_response = subprocess.run(
@@ -224,11 +224,22 @@ def get_test_response() -> list[dict]:
224 return json.loads(fastfetch_response.stdout) 224 return json.loads(fastfetch_response.stdout)
225 225
226 226
227def filter_roots(roots) -> list[Node]: 227def filter_roots(roots: list[Node], data: list[dict]) -> list[Node]:
228 skip_modules = ["Custom"] 228 skip_modules = ["Custom"]
229 for response_object in get_test_response(): 229 for response_object in data:
230 if response_object.get("error") and response_object.get("type") not in skip_modules or response_object.get("result") == []: 230 if response_object.get("error") and response_object.get("type") not in skip_modules or response_object.get("result") == []:
231 for root in roots: 231 for root in roots:
232 root.remove_module(response_object.get("type").lower()) 232 root.remove_module(response_object.get("type").lower())
233 return roots 233 return roots
234 234
235
236def main():
237 test_config = build_config(roots)
238 test_data = get_test_response(test_config)
239 filtered_roots = filter_roots(roots, test_data)
240 final_config = build_config(filtered_roots)
241 print(json.dumps(final_config))
242
243
244if __name__ == '__main__':
245 main()