diff options
| author | Pavel Egorov <[email protected]> | 2025-12-19 06:09:15 +0300 |
|---|---|---|
| committer | Pavel Egorov <[email protected]> | 2025-12-19 06:09:15 +0300 |
| commit | 9587c2cecbb1d278c264db16dbd876fa9579a9b0 (patch) | |
| tree | 9b5b536f18e7705aa25017f8097d244336111163 | |
| parent | 9e037c2b066eae68c0df6cc2885ed2e2e6a45af8 (diff) | |
| download | dotfiles-9587c2cecbb1d278c264db16dbd876fa9579a9b0.tar.gz dotfiles-9587c2cecbb1d278c264db16dbd876fa9579a9b0.zip | |
[fastfetch] rewrite color handling
Diffstat (limited to '')
| -rw-r--r-- | .config/fastfetch/confgen.py | 36 |
1 files changed, 26 insertions, 10 deletions
diff --git a/.config/fastfetch/confgen.py b/.config/fastfetch/confgen.py index aa64f6a..02eb791 100644 --- a/.config/fastfetch/confgen.py +++ b/.config/fastfetch/confgen.py | |||
| @@ -66,7 +66,9 @@ class Node: | |||
| 66 | def prettify(self, font_effect="", key_prefix="") -> None: | 66 | def prettify(self, font_effect="", key_prefix="") -> None: |
| 67 | if self.font_effect: | 67 | if self.font_effect: |
| 68 | font_effect = self.font_effect | 68 | font_effect = self.font_effect |
| 69 | self.key = font_effect + self.key | 69 | |
| 70 | # bold for category roots | ||
| 71 | self.key = font_effect + BOLD_CODE + self.key | ||
| 70 | 72 | ||
| 71 | if len(key_prefix): | 73 | if len(key_prefix): |
| 72 | self.key = key_prefix + f'{graphics["hbar"]} ' + self.key | 74 | self.key = key_prefix + f'{graphics["hbar"]} ' + self.key |
| @@ -83,16 +85,30 @@ class Node: | |||
| 83 | node.prettify(font_effect, key_prefix + font_effect + graphics["branch"]) | 85 | node.prettify(font_effect, key_prefix + font_effect + graphics["branch"]) |
| 84 | 86 | ||
| 85 | 87 | ||
| 88 | CSI = '\033[' | ||
| 89 | SGR = 'm' | ||
| 90 | BOLD = 1 | ||
| 91 | BOLD_CODE = f"{CSI}{BOLD}{SGR}" | ||
| 92 | |||
| 93 | |||
| 94 | def fg(r, g, b): | ||
| 95 | FORE = 38 | ||
| 96 | TRUE_COLOR = 2 | ||
| 97 | THIN_COLOR = 22 | ||
| 98 | thin_code = f"{CSI}{THIN_COLOR}{SGR}" | ||
| 99 | return f"{thin_code}{CSI}{FORE};{TRUE_COLOR};{r};{g};{b}{SGR}" | ||
| 100 | |||
| 101 | |||
| 86 | font_effects = { | 102 | font_effects = { |
| 87 | "reset": "{#0}", | 103 | "reset": f"{CSI}{SGR}", |
| 88 | "software": "\u001b[38;2;0;255;0m", | 104 | "software": fg(0, 255, 0), |
| 89 | "os": "\u001b[38;2;0;255;60m", | 105 | "os": fg(0, 255, 60), |
| 90 | "terminal": "\u001b[38;2;0;255;120m", | 106 | "terminal": fg(0, 255, 120), |
| 91 | "graphics": "\u001b[38;2;0;255;180m", | 107 | "graphics": fg(0, 255, 180), |
| 92 | "development": "\u001b[38;2;0;255;240m", | 108 | "development": fg(0, 255, 240), |
| 93 | "hardware": "\u001b[38;2;255;255;0m", | 109 | "hardware": fg(255, 255, 0), |
| 94 | "chassis": "\u001b[38;2;255;180;0m", | 110 | "chassis": fg(255, 180, 0), |
| 95 | "miscellaneous": "\u001b[38;2;195;120;225m", | 111 | "miscellaneous": fg(195, 120, 225), |
| 96 | } | 112 | } |
| 97 | 113 | ||
| 98 | graphics = { | 114 | graphics = { |
