summaryrefslogtreecommitdiffstats
path: root/.config/fastfetch/confgen.py
diff options
context:
space:
mode:
authorPavel Egorov <[email protected]>2025-12-16 06:47:35 +0300
committerPavel Egorov <[email protected]>2025-12-16 06:47:35 +0300
commit3883f3e91b50ff8a29a0691bab5f9bfeff78d111 (patch)
tree27e738736665d12bf87db156025c4b70d0dd9511 /.config/fastfetch/confgen.py
parent27576bb3c0ee8deff6178b9605b06c2bb85e192a (diff)
downloaddotfiles-3883f3e91b50ff8a29a0691bab5f9bfeff78d111.tar.gz
dotfiles-3883f3e91b50ff8a29a0691bab5f9bfeff78d111.zip
[fastfetch] Create class for constructing fastfetch module desctiptions
Diffstat (limited to '.config/fastfetch/confgen.py')
-rw-r--r--.config/fastfetch/confgen.py84
1 files changed, 84 insertions, 0 deletions
diff --git a/.config/fastfetch/confgen.py b/.config/fastfetch/confgen.py
new file mode 100644
index 0000000..92ed0d3
--- /dev/null
+++ b/.config/fastfetch/confgen.py
@@ -0,0 +1,84 @@
1#!/usr/bin/env python3
2
3from typing import Optional
4
5
6class Node:
7 module: str
8 key: str
9 format: Optional[str]
10 text: Optional[str]
11 font_effect: Optional[str]
12 neighbour_branches: str
13 children: list["Node"] = []
14
15 def __init__(self, module, key, format=None, text=None, font_effect=None):
16 self.module = module
17 self.key = key
18 self.format = format
19 self.text = text
20 self.font_effect = font_effect
21
22 def __str__(self) -> str:
23 return str(self.construct_fastfetch_description())
24
25 def construct_fastfetch_description(self) -> dict[str, str]:
26
27 module = {"type": self.module}
28
29 if self.font_effect:
30 font_effect = self.font_effect
31 else:
32 font_effect = font_effects["reset"]
33 key = {"key": f"{{{font_effect}}} {self.key}"}
34
35 if self.format:
36 format = self.format
37 else:
38 format = {}
39
40 if self.text:
41 text = self.text
42 else:
43 text = {}
44
45 return module | key | format | text
46
47 def add_children(self, *nodes: type["Node"]):
48 for node in nodes:
49 self.children.append(node)
50
51
52schema = {
53 "$schema": "https://github.com/fastfetch-cli/fastfetch/raw/dev/doc/json_schema.json"
54}
55
56logo = {"padding": {"left": 3, "right": 3, "top": 3}}
57
58font_effects = {
59 "reset": "#0",
60 "software": "\u001b[38;2;0;255;0m",
61 "os": "\u001b[38;2;0;255;60m",
62 "terminal": "\u001b[38;2;0;255;120m",
63 "graphics": "\u001b[38;2;0;255;180m",
64 "development": "\u001b[38;2;0;255;240m",
65 "hardware": "\u001b[38;2;255;255;0m",
66 "chassis": "\u001b[38;2;255;180;0m",
67 "miscellaneous": "\u001b[38;2;195;120;225m",
68}
69
70graphics = {
71 "branch": "├",
72 "vbar": "│",
73 "end": "└",
74 "hbar": "─",
75}
76
77modules = {
78 "software_root": Node("custom", "Software", font_effect=font_effects["software"]),
79 "os": Node("os", "OS"),
80}
81
82modules["software_root"].add_children(modules["os"])
83
84print(modules["software_root"])