synth-shell-theme 1.3.9__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- synth_shell_theme/__init__.py +7 -0
- synth_shell_theme/__main__.py +8 -0
- synth_shell_theme/assets/studio.html +1920 -0
- synth_shell_theme/cli.py +887 -0
- synth_shell_theme/core.py +1695 -0
- synth_shell_theme/ecosystem.py +537 -0
- synth_shell_theme/patches.py +1853 -0
- synth_shell_theme/paths.py +363 -0
- synth_shell_theme/separators.py +320 -0
- synth_shell_theme/server.py +506 -0
- synth_shell_theme/themes/01-screenshot-match.conf +30 -0
- synth_shell_theme/themes/02-current-live-theme.conf +30 -0
- synth_shell_theme/themes/03-dracula-punch.conf +30 -0
- synth_shell_theme/themes/04-nord-ice.conf +30 -0
- synth_shell_theme/themes/05-matrix-green.conf +30 -0
- synth_shell_theme/themes/06-amber-heat.conf +30 -0
- synth_shell_theme/themes/07-cloud-ops.conf +30 -0
- synth_shell_theme/themes/08-catppuccin-mauve.conf +30 -0
- synth_shell_theme/themes/09-solarized-night.conf +30 -0
- synth_shell_theme/themes/10-gruvbox-dark.conf +30 -0
- synth_shell_theme/themes/11-monokai-neon.conf +30 -0
- synth_shell_theme/themes/12-tokyo-night.conf +30 -0
- synth_shell_theme/themes/13-synthwave-pink.conf +30 -0
- synth_shell_theme/themes/14-forest-mint.conf +30 -0
- synth_shell_theme/themes/15-ruby-steel.conf +30 -0
- synth_shell_theme/themes/16-ice-gold.conf +30 -0
- synth_shell_theme/themes/17-aqua-slate.conf +30 -0
- synth_shell_theme/themes/18-cyber-lime.conf +30 -0
- synth_shell_theme/themes/19-lavender-sunset.conf +30 -0
- synth_shell_theme/themes/20-minimal-mono.conf +30 -0
- synth_shell_theme/themes/21-rose-pine.conf +30 -0
- synth_shell_theme/themes/22-kanagawa.conf +30 -0
- synth_shell_theme/themes/23-everforest.conf +30 -0
- synth_shell_theme/themes/24-one-dark.conf +30 -0
- synth_shell_theme/themes/25-ayu-dark.conf +30 -0
- synth_shell_theme/themes/26-nightfox.conf +30 -0
- synth_shell_theme/themes/27-palenight.conf +30 -0
- synth_shell_theme/themes/28-cyberdream.conf +30 -0
- synth_shell_theme/themes/29-moonlight.conf +30 -0
- synth_shell_theme/themes/30-poimandres.conf +30 -0
- synth_shell_theme/themes/31-tokyo-storm.conf +30 -0
- synth_shell_theme/themes/32-catppuccin-mocha.conf +30 -0
- synth_shell_theme/themes/33-nordic-aurora.conf +30 -0
- synth_shell_theme/themes/34-horizon-synth.conf +30 -0
- synth_shell_theme/themes/35-gruvbox-material.conf +30 -0
- synth_shell_theme/themes/36-oxocarbon.conf +30 -0
- synth_shell_theme/themes/37-catppuccin-latte.conf +30 -0
- synth_shell_theme/themes/38-tokyo-twilight.conf +30 -0
- synth_shell_theme/themes/39-solarized-ocean.conf +30 -0
- synth_shell_theme/themes/40-vaporwave-sunset.conf +30 -0
- synth_shell_theme/themes/41-deep-abyss.conf +30 -0
- synth_shell_theme/themes/42-sakura-blossom.conf +30 -0
- synth_shell_theme/themes/43-emerald-forest.conf +30 -0
- synth_shell_theme/themes/44-vesper.conf +30 -0
- synth_shell_theme/themes/45-cobalt-neon.conf +30 -0
- synth_shell_theme/themes/46-desert-dunes.conf +30 -0
- synth_shell_theme/themes/47-cyber-samurai.conf +30 -0
- synth_shell_theme/themes/48-glacier-mint.conf +30 -0
- synth_shell_theme/themes/49-carbon-titanium.conf +30 -0
- synth_shell_theme/themes/50-matcha-latte.conf +30 -0
- synth_shell_theme/themes/51-volcanic-magma.conf +30 -0
- synth_shell_theme/themes/52-catppuccin-frappe.conf +30 -0
- synth_shell_theme/themes/53-bioluminescence.conf +30 -0
- synth_shell_theme/themes/54-mocha-caramel.conf +30 -0
- synth_shell_theme/themes/55-neon-genesis.conf +30 -0
- synth_shell_theme/themes/56-midnight-amethyst.conf +30 -0
- synth_shell_theme/themes/57-andromeda.conf +30 -0
- synth_shell_theme/themes/58-golden-velvet.conf +30 -0
- synth_shell_theme/themes/59-miami-vice.conf +30 -0
- synth_shell_theme/themes/60-zen-garden.conf +30 -0
- synth_shell_theme/themes/61-google-cloud.conf +30 -0
- synth_shell_theme/themes/62-github-dark.conf +30 -0
- synth_shell_theme/themes/63-cyberpunk-edgerunners.conf +30 -0
- synth_shell_theme/themes/64-vscode-dark.conf +30 -0
- synth_shell_theme/themes.py +580 -0
- synth_shell_theme/tui.py +632 -0
- synth_shell_theme-1.3.9.dist-info/METADATA +261 -0
- synth_shell_theme-1.3.9.dist-info/RECORD +82 -0
- synth_shell_theme-1.3.9.dist-info/WHEEL +5 -0
- synth_shell_theme-1.3.9.dist-info/entry_points.txt +3 -0
- synth_shell_theme-1.3.9.dist-info/licenses/LICENSE +21 -0
- synth_shell_theme-1.3.9.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,363 @@
|
|
|
1
|
+
"""Cross-platform path discovery, font/locale diagnostics, and terminal helpers for synth-shell-theme."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import locale
|
|
6
|
+
import os
|
|
7
|
+
import platform
|
|
8
|
+
import shutil
|
|
9
|
+
import subprocess
|
|
10
|
+
import sys
|
|
11
|
+
from pathlib import Path
|
|
12
|
+
|
|
13
|
+
_NERD_FONT_TOKENS = (
|
|
14
|
+
"nerd",
|
|
15
|
+
"powerline",
|
|
16
|
+
"meslolgs",
|
|
17
|
+
"caskaydia",
|
|
18
|
+
"firacode",
|
|
19
|
+
"jetbrainsmono",
|
|
20
|
+
"hack nerd",
|
|
21
|
+
"blexmono",
|
|
22
|
+
"iosevka nf",
|
|
23
|
+
"symbols nerd",
|
|
24
|
+
" nf",
|
|
25
|
+
" nfm",
|
|
26
|
+
" nfp",
|
|
27
|
+
" pl",
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def detect_os() -> str:
|
|
32
|
+
"""Return normalized OS identifier ('linux', 'macos', or 'windows')."""
|
|
33
|
+
plat = sys.platform.lower()
|
|
34
|
+
if plat.startswith("win"):
|
|
35
|
+
return "windows"
|
|
36
|
+
if plat == "darwin":
|
|
37
|
+
return "macos"
|
|
38
|
+
return "linux"
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def setup_console() -> None:
|
|
42
|
+
"""Configure UTF-8 console output and enable ANSI VT100 sequences on Windows if needed."""
|
|
43
|
+
for stream_name in ("stdout", "stderr"):
|
|
44
|
+
stream = getattr(sys, stream_name, None)
|
|
45
|
+
reconfigure = getattr(stream, "reconfigure", None)
|
|
46
|
+
if callable(reconfigure):
|
|
47
|
+
try:
|
|
48
|
+
reconfigure(encoding="utf-8", errors="replace")
|
|
49
|
+
except Exception:
|
|
50
|
+
pass
|
|
51
|
+
|
|
52
|
+
if sys.platform.startswith("win"):
|
|
53
|
+
try:
|
|
54
|
+
import ctypes
|
|
55
|
+
|
|
56
|
+
kernel32 = ctypes.windll.kernel32 # type: ignore[attr-defined]
|
|
57
|
+
handle = kernel32.GetStdHandle(-11) # STD_OUTPUT_HANDLE
|
|
58
|
+
mode = ctypes.c_ulong()
|
|
59
|
+
if kernel32.GetConsoleMode(handle, ctypes.byref(mode)):
|
|
60
|
+
kernel32.SetConsoleMode(handle, mode.value | 0x0004)
|
|
61
|
+
except Exception:
|
|
62
|
+
pass
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def get_config_dir() -> Path:
|
|
66
|
+
"""Return the synth-shell configuration directory (overridable via SYNTH_SHELL_CONFIG_DIR)."""
|
|
67
|
+
override = os.environ.get("SYNTH_SHELL_CONFIG_DIR", "").strip()
|
|
68
|
+
if override:
|
|
69
|
+
return Path(override).expanduser()
|
|
70
|
+
return Path.home() / ".config" / "synth-shell"
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
def get_config_path(config_dir: Path | None = None) -> Path:
|
|
74
|
+
"""Return the path to `synth-shell-prompt.config`."""
|
|
75
|
+
base = config_dir if config_dir is not None else get_config_dir()
|
|
76
|
+
return base / "synth-shell-prompt.config"
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
def get_root_config_path(config_dir: Path | None = None) -> Path:
|
|
80
|
+
"""Return the path to `synth-shell-prompt.root.config`."""
|
|
81
|
+
base = config_dir if config_dir is not None else get_config_dir()
|
|
82
|
+
return base / "synth-shell-prompt.root.config"
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
def get_prompt_script_path(config_dir: Path | None = None) -> Path:
|
|
86
|
+
"""Return the path to `synth-shell-prompt.sh`."""
|
|
87
|
+
base = config_dir if config_dir is not None else get_config_dir()
|
|
88
|
+
return base / "synth-shell-prompt.sh"
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
def get_greeter_config_path(config_dir: Path | None = None) -> Path:
|
|
92
|
+
"""Return the path to `synth-shell-greeter.config` (or legacy `status.config` if present)."""
|
|
93
|
+
base = config_dir if config_dir is not None else get_config_dir()
|
|
94
|
+
primary = base / "synth-shell-greeter.config"
|
|
95
|
+
legacy = base / "status.config"
|
|
96
|
+
if primary.is_file() or not legacy.is_file():
|
|
97
|
+
return primary
|
|
98
|
+
return legacy
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
def get_greeter_script_path(config_dir: Path | None = None) -> Path:
|
|
102
|
+
"""Return the path to `synth-shell-greeter.sh` (or legacy `status.sh` if present)."""
|
|
103
|
+
base = config_dir if config_dir is not None else get_config_dir()
|
|
104
|
+
primary = base / "synth-shell-greeter.sh"
|
|
105
|
+
legacy = base / "status.sh"
|
|
106
|
+
if primary.is_file() or not legacy.is_file():
|
|
107
|
+
return primary
|
|
108
|
+
return legacy
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
def get_backup_dir(config_dir: Path | None = None) -> Path:
|
|
112
|
+
"""Return the directory used for timestamped configuration backups."""
|
|
113
|
+
base = config_dir if config_dir is not None else get_config_dir()
|
|
114
|
+
return base / "backups"
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
def get_package_dir() -> Path:
|
|
118
|
+
"""Return the installed package root directory."""
|
|
119
|
+
return Path(__file__).resolve().parent
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
def get_themes_dir() -> Path:
|
|
123
|
+
"""Return the bundled `themes/` directory containing the 64 `.conf` files."""
|
|
124
|
+
return get_package_dir() / "themes"
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
def get_user_themes_dir(config_dir: Path | None = None) -> Path:
|
|
128
|
+
"""Return the user custom themes directory (`~/.config/synth-shell/themes`)."""
|
|
129
|
+
base = config_dir if config_dir is not None else get_config_dir()
|
|
130
|
+
return base / "themes"
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
def get_assets_dir() -> Path:
|
|
134
|
+
"""Return the bundled `assets/` directory containing `studio.html`."""
|
|
135
|
+
return get_package_dir() / "assets"
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
def detect_terminal_capabilities(nerd_fonts: dict[str, object] | None = None) -> dict[str, object]:
|
|
139
|
+
"""Inspect TERM, COLORTERM (24-bit TrueColor), TERM_PROGRAM (VS Code), tmux, and ble.sh."""
|
|
140
|
+
term = os.environ.get("TERM", "")
|
|
141
|
+
colorterm = os.environ.get("COLORTERM", "")
|
|
142
|
+
term_program = os.environ.get("TERM_PROGRAM", "")
|
|
143
|
+
in_tmux = bool(os.environ.get("TMUX"))
|
|
144
|
+
truecolor = colorterm.lower() in ("truecolor", "24bit")
|
|
145
|
+
term_256 = "256color" in term.lower() or "truecolor" in term.lower() or truecolor
|
|
146
|
+
blesh_installed = bool(os.environ.get("BLE_VERSION")) or (Path.home() / ".local" / "share" / "blesh" / "ble.sh").is_file()
|
|
147
|
+
|
|
148
|
+
nf = nerd_fonts if nerd_fonts is not None else detect_nerd_fonts()
|
|
149
|
+
samples = list(nf.get("samples", [])) if isinstance(nf, dict) else [] # type: ignore[arg-type]
|
|
150
|
+
rec_font = str(samples[0]) if samples else "CaskaydiaCove Nerd Font"
|
|
151
|
+
|
|
152
|
+
return {
|
|
153
|
+
"term": term or "unset",
|
|
154
|
+
"colorterm": colorterm or "unset",
|
|
155
|
+
"truecolor": truecolor,
|
|
156
|
+
"term_256": term_256,
|
|
157
|
+
"term_program": term_program or "unknown",
|
|
158
|
+
"is_vscode": term_program.lower() == "vscode",
|
|
159
|
+
"in_tmux": in_tmux,
|
|
160
|
+
"blesh_detected": blesh_installed,
|
|
161
|
+
"vscode_font_setting": f'"terminal.integrated.fontFamily": "{rec_font}"',
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
def detect_utf8_locale() -> dict[str, object]:
|
|
166
|
+
"""Inspect active shell locale variables and encoding to determine UTF-8 readiness."""
|
|
167
|
+
lc_all = os.environ.get("LC_ALL", "")
|
|
168
|
+
lc_ctype = os.environ.get("LC_CTYPE", "")
|
|
169
|
+
lang = os.environ.get("LANG", "")
|
|
170
|
+
preferred = locale.getpreferredencoding(False) or ""
|
|
171
|
+
|
|
172
|
+
effective = lc_all or lc_ctype or lang
|
|
173
|
+
norm_eff = effective.lower().replace("-", "")
|
|
174
|
+
norm_pref = preferred.lower().replace("-", "")
|
|
175
|
+
|
|
176
|
+
if effective:
|
|
177
|
+
is_utf8 = "utf8" in norm_eff
|
|
178
|
+
else:
|
|
179
|
+
is_utf8 = "utf8" in norm_pref
|
|
180
|
+
|
|
181
|
+
return {
|
|
182
|
+
"utf8": is_utf8,
|
|
183
|
+
"encoding": preferred,
|
|
184
|
+
"effective": effective or preferred or "unknown",
|
|
185
|
+
"lang": lang,
|
|
186
|
+
"lc_all": lc_all,
|
|
187
|
+
"lc_ctype": lc_ctype,
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
def _matches_nerd_font(name: str) -> bool:
|
|
192
|
+
low = name.lower()
|
|
193
|
+
return any(tok in low for tok in _NERD_FONT_TOKENS)
|
|
194
|
+
|
|
195
|
+
|
|
196
|
+
def detect_nerd_fonts() -> dict[str, object]:
|
|
197
|
+
"""Scan local font registry/directories for installed Nerd Font or Powerline fonts."""
|
|
198
|
+
matches: list[str] = []
|
|
199
|
+
seen: set[str] = set()
|
|
200
|
+
os_name = detect_os()
|
|
201
|
+
|
|
202
|
+
def _add(font_name: str) -> None:
|
|
203
|
+
clean = font_name.strip()
|
|
204
|
+
if not clean:
|
|
205
|
+
return
|
|
206
|
+
key = clean.lower()
|
|
207
|
+
if key not in seen and _matches_nerd_font(clean):
|
|
208
|
+
seen.add(key)
|
|
209
|
+
matches.append(clean)
|
|
210
|
+
|
|
211
|
+
fc_list = shutil.which("fc-list")
|
|
212
|
+
if fc_list:
|
|
213
|
+
try:
|
|
214
|
+
proc = subprocess.run(
|
|
215
|
+
[fc_list, ":", "family"],
|
|
216
|
+
capture_output=True,
|
|
217
|
+
text=True,
|
|
218
|
+
timeout=2.5,
|
|
219
|
+
check=False,
|
|
220
|
+
)
|
|
221
|
+
if proc.returncode == 0:
|
|
222
|
+
for line in proc.stdout.splitlines():
|
|
223
|
+
for fam in line.split(","):
|
|
224
|
+
_add(fam)
|
|
225
|
+
except Exception:
|
|
226
|
+
pass
|
|
227
|
+
|
|
228
|
+
if not matches:
|
|
229
|
+
font_dirs: list[Path] = []
|
|
230
|
+
if os_name == "macos":
|
|
231
|
+
font_dirs = [Path.home() / "Library" / "Fonts", Path("/Library/Fonts")]
|
|
232
|
+
elif os_name == "windows":
|
|
233
|
+
local_app = os.environ.get("LOCALAPPDATA", "")
|
|
234
|
+
if local_app:
|
|
235
|
+
font_dirs.append(Path(local_app) / "Microsoft" / "Windows" / "Fonts")
|
|
236
|
+
font_dirs.append(Path("C:/Windows/Fonts"))
|
|
237
|
+
else:
|
|
238
|
+
font_dirs = [
|
|
239
|
+
Path.home() / ".local" / "share" / "fonts",
|
|
240
|
+
Path.home() / ".fonts",
|
|
241
|
+
Path("/usr/local/share/fonts"),
|
|
242
|
+
Path("/usr/share/fonts"),
|
|
243
|
+
]
|
|
244
|
+
|
|
245
|
+
for fdir in font_dirs:
|
|
246
|
+
if not fdir.is_dir():
|
|
247
|
+
continue
|
|
248
|
+
try:
|
|
249
|
+
for root, _dirs, files in os.walk(fdir):
|
|
250
|
+
for fname in files:
|
|
251
|
+
if fname.lower().endswith((".ttf", ".otf", ".ttc")):
|
|
252
|
+
_add(Path(fname).stem)
|
|
253
|
+
if len(matches) >= 30:
|
|
254
|
+
break
|
|
255
|
+
if len(matches) >= 30:
|
|
256
|
+
break
|
|
257
|
+
except OSError:
|
|
258
|
+
continue
|
|
259
|
+
|
|
260
|
+
matches.sort()
|
|
261
|
+
return {
|
|
262
|
+
"detected": bool(matches),
|
|
263
|
+
"count": len(matches),
|
|
264
|
+
"samples": matches[:6],
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
|
|
268
|
+
def detect_system_color_scheme() -> str:
|
|
269
|
+
"""Detect OS dark/light preference (`'dark'` or `'light'`, defaulting to `'dark'`)."""
|
|
270
|
+
os_name = detect_os()
|
|
271
|
+
if os_name == "macos":
|
|
272
|
+
try:
|
|
273
|
+
r = subprocess.run(
|
|
274
|
+
["defaults", "read", "-g", "AppleInterfaceStyle"],
|
|
275
|
+
capture_output=True,
|
|
276
|
+
text=True,
|
|
277
|
+
timeout=1.5,
|
|
278
|
+
check=False,
|
|
279
|
+
)
|
|
280
|
+
return "dark" if r.returncode == 0 and "dark" in r.stdout.lower() else "light"
|
|
281
|
+
except (OSError, subprocess.SubprocessError):
|
|
282
|
+
return "dark"
|
|
283
|
+
if os_name == "windows":
|
|
284
|
+
try:
|
|
285
|
+
import winreg # type: ignore[import-not-found]
|
|
286
|
+
|
|
287
|
+
key = winreg.OpenKey(
|
|
288
|
+
winreg.HKEY_CURRENT_USER,
|
|
289
|
+
r"Software\Microsoft\Windows\CurrentVersion\Themes\Personalize",
|
|
290
|
+
)
|
|
291
|
+
val, _ = winreg.QueryValueEx(key, "AppsUseLightTheme")
|
|
292
|
+
winreg.CloseKey(key)
|
|
293
|
+
return "light" if int(val) == 1 else "dark"
|
|
294
|
+
except Exception:
|
|
295
|
+
return "dark"
|
|
296
|
+
# Linux: GNOME gsettings -> KDE kdeglobals fallback
|
|
297
|
+
if shutil.which("gsettings"):
|
|
298
|
+
try:
|
|
299
|
+
r = subprocess.run(
|
|
300
|
+
["gsettings", "get", "org.gnome.desktop.interface", "color-scheme"],
|
|
301
|
+
capture_output=True,
|
|
302
|
+
text=True,
|
|
303
|
+
timeout=1.5,
|
|
304
|
+
check=False,
|
|
305
|
+
)
|
|
306
|
+
out = r.stdout.strip().lower()
|
|
307
|
+
if "light" in out:
|
|
308
|
+
return "light"
|
|
309
|
+
if "dark" in out:
|
|
310
|
+
return "dark"
|
|
311
|
+
except (OSError, subprocess.SubprocessError):
|
|
312
|
+
pass
|
|
313
|
+
kde_cfg = Path.home() / ".config" / "kdeglobals"
|
|
314
|
+
if kde_cfg.is_file():
|
|
315
|
+
try:
|
|
316
|
+
txt = kde_cfg.read_text(encoding="utf-8", errors="replace").lower()
|
|
317
|
+
if "breezelight" in txt or "colorscheme=light" in txt:
|
|
318
|
+
return "light"
|
|
319
|
+
except OSError:
|
|
320
|
+
pass
|
|
321
|
+
return "dark"
|
|
322
|
+
|
|
323
|
+
|
|
324
|
+
def system_summary(config_dir: Path | None = None) -> dict[str, object]:
|
|
325
|
+
"""Return environment and installation diagnostics for `synth-shell-theme doctor`."""
|
|
326
|
+
base = config_dir if config_dir is not None else get_config_dir()
|
|
327
|
+
cfg = get_config_path(base)
|
|
328
|
+
root_cfg = get_root_config_path(base)
|
|
329
|
+
prompt_sh = get_prompt_script_path(base)
|
|
330
|
+
greeter_cfg = get_greeter_config_path(base)
|
|
331
|
+
greeter_sh = get_greeter_script_path(base)
|
|
332
|
+
bdir = get_backup_dir(base)
|
|
333
|
+
backups = sorted(bdir.glob("synth-shell-prompt.config.*.bak")) if bdir.is_dir() else []
|
|
334
|
+
|
|
335
|
+
nf = detect_nerd_fonts()
|
|
336
|
+
return {
|
|
337
|
+
"os": detect_os(),
|
|
338
|
+
"platform": platform.platform(),
|
|
339
|
+
"python": sys.version.split()[0],
|
|
340
|
+
"config_dir": str(base),
|
|
341
|
+
"config_path": str(cfg),
|
|
342
|
+
"config_exists": cfg.is_file(),
|
|
343
|
+
"root_config_path": str(root_cfg),
|
|
344
|
+
"root_config_exists": root_cfg.is_file(),
|
|
345
|
+
"prompt_script_path": str(prompt_sh),
|
|
346
|
+
"prompt_script_exists": prompt_sh.is_file(),
|
|
347
|
+
"greeter_config_path": str(greeter_cfg),
|
|
348
|
+
"greeter_config_exists": greeter_cfg.is_file(),
|
|
349
|
+
"greeter_script_path": str(greeter_sh),
|
|
350
|
+
"greeter_script_exists": greeter_sh.is_file(),
|
|
351
|
+
"backup_dir": str(bdir),
|
|
352
|
+
"backup_count": len(backups),
|
|
353
|
+
"bash_found": shutil.which("bash") is not None,
|
|
354
|
+
"git_found": shutil.which("git") is not None,
|
|
355
|
+
"themes_dir": str(get_themes_dir()),
|
|
356
|
+
"user_themes_dir": str(get_user_themes_dir(base)),
|
|
357
|
+
"bundled_themes": len(list(get_themes_dir().glob("*.conf"))),
|
|
358
|
+
"custom_themes": len(list(get_user_themes_dir(base).glob("*.conf"))) if get_user_themes_dir(base).is_dir() else 0,
|
|
359
|
+
"locale": detect_utf8_locale(),
|
|
360
|
+
"nerd_fonts": nf,
|
|
361
|
+
"terminal": detect_terminal_capabilities(nf),
|
|
362
|
+
"system_theme": detect_system_color_scheme(),
|
|
363
|
+
}
|
|
@@ -0,0 +1,320 @@
|
|
|
1
|
+
"""Curated Powerline separator presets (48 styles) and 60+ Nerd Font character palette."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import re
|
|
6
|
+
|
|
7
|
+
CATEGORIES: dict[str, list[tuple[str, str, str, str]]] = {
|
|
8
|
+
"Powerline Solid (Hard Dividers)": [
|
|
9
|
+
("arrow", "\ue0b0", "\\uE0B0", "Classic Triangle Arrow (Powerline iconic)"),
|
|
10
|
+
("round", "\ue0b4", "\\uE0B4", "Rounded Bubble / Capsule (Modern pill)"),
|
|
11
|
+
("slant", "\ue0bc", "\\uE0BC", "Angled Slant Lower (Forward diagonal cut)"),
|
|
12
|
+
("slant-up", "\ue0be", "\\uE0BE", "Angled Slant Upper (Reverse diagonal cut)"),
|
|
13
|
+
("flame", "\ue0c0", "\\uE0C0", "Flame / Fire Spikes (Energetic serrated edge)"),
|
|
14
|
+
("pixel", "\ue0c4", "\\uE0C4", "8-Bit Stepped Pixel / Lego (Retro arcade)"),
|
|
15
|
+
("wave", "\ue0ca", "\\uE0CA", "Sine Wave / S-Curve (Fluid organic flow)"),
|
|
16
|
+
("hex", "\ue0cc", "\\uE0CC", "Hexagon / Honeycomb (Sci-fi cyber HUD)"),
|
|
17
|
+
("ice", "\ue0c8", "\\uE0C8", "Ice / Trapezoid Notch (Crystalline cut)"),
|
|
18
|
+
("sharp-slant", "\ue0d4", "\\uE0D4", "Sharp Slant Right (Crisp angular blade)"),
|
|
19
|
+
("trapezoid", "\ue0d2", "\\uE0D2", "Big Trapezoid Right (Bold wedge cut)"),
|
|
20
|
+
],
|
|
21
|
+
"Powerline Thin (Soft Dividers)": [
|
|
22
|
+
("thin-arrow", "\ue0b1", "\\uE0B1", "Thin Outline Triangle (Minimalist soft divider)"),
|
|
23
|
+
("thin-round", "\ue0b5", "\\uE0B5", "Thin Outline Bubble (Subtle rounded pill)"),
|
|
24
|
+
("thin-flame", "\ue0c1", "\\uE0C1", "Thin Outline Flame (Delicate spike wireframe)"),
|
|
25
|
+
("thin-hex", "\ue0cd", "\\uE0CD", "Thin Outline Hexagon (Wireframe cyber mesh)"),
|
|
26
|
+
],
|
|
27
|
+
"Geometric & Minimalist": [
|
|
28
|
+
("slash", "\u2571", "\\u2571", "Diagonal Line Slash (Architectural clean cut)"),
|
|
29
|
+
("backslash", "\u2572", "\\u2572", "Backslash Line Slash (Reverse angle cut)"),
|
|
30
|
+
("bar", "\u2502", "\\u2502", "Light Vertical Bar / Pipe (Nordic subtle separator)"),
|
|
31
|
+
("heavy-bar", "\u2503", "\\u2503", "Heavy Vertical Bar (Bold column divider)"),
|
|
32
|
+
("half-block", "\u258c", "\\u258C", "Left Half Solid Block (Staccato block divider)"),
|
|
33
|
+
("diamond", "\u25c6", "\\u25C6", "Solid Diamond (Geometric accent)"),
|
|
34
|
+
("bullet", "\u25cf", "\\u25CF", "Solid Bullet Circle (Centered dot spacer)"),
|
|
35
|
+
],
|
|
36
|
+
"Chevrons & Terminal Arrows": [
|
|
37
|
+
("chevron", "\u00bb", "\\u00BB", "Double Angle Chevron (Fast-forward prompt)"),
|
|
38
|
+
("single-chevron", "\u203a", "\\u203A", "Single Angle Chevron (Compact breadcrumb)"),
|
|
39
|
+
("arrow-right", "\u2192", "\\u2192", "Clean Thin Right Arrow (Modern minimal pointer)"),
|
|
40
|
+
("heavy-arrow", "\u27a4", "\\u27A4", "Black Rightwards Arrowhead (Bold navigation dart)"),
|
|
41
|
+
("octicon-chevron", "\uf460", "\\uF460", "Octicon Chevron Right (GitHub Octicon glyph)"),
|
|
42
|
+
("fa-angle", "\uf105", "\\uF105", "FontAwesome Angle Right (UI breadcrumb angle)"),
|
|
43
|
+
],
|
|
44
|
+
"Nerd Font Glyphs & Emblems": [
|
|
45
|
+
("star", "\u2605", "\\u2605", "Solid Star (Clean celestial emblem)"),
|
|
46
|
+
("rocket", "\uf135", "\\uF135", "FontAwesome Rocket (Fast launch emblem)"),
|
|
47
|
+
("lock", "\uf023", "\\uF023", "FontAwesome Lock (Security / prod context)"),
|
|
48
|
+
("git", "\ue725", "\\uE725", "Git Branch Icon"),
|
|
49
|
+
("terminal", "\ue271", "\\uE271", "Terminal Command Icon"),
|
|
50
|
+
],
|
|
51
|
+
"Electricity, Sparks & High Voltage": [
|
|
52
|
+
("zap", "\u26a1", "\\u26A1", "Classic Zap Bolt (High-voltage electric energy)"),
|
|
53
|
+
("lightning", "\uf0e7", "\\uF0E7", "FontAwesome Solid Lightning Bolt"),
|
|
54
|
+
("thunder", "\u21af", "\\u21AF", "Zigzag Downward Thunder Discharge"),
|
|
55
|
+
("flash", "\U000f140b", "\\U000F140B", "Material Modern Sharp Lightning"),
|
|
56
|
+
("flash-wire", "\U000f140c", "\\U000F140C", "Material Wireframe Lightning"),
|
|
57
|
+
("sparkle", "\u2726", "\\u2726", "Four-Point Diamond Energy Sparkle"),
|
|
58
|
+
("starburst", "\u2727", "\\u2727", "Four-Point Hollow Starburst Flare"),
|
|
59
|
+
("burst", "\u2739", "\\u2739", "Twelve-Point Starburst Plasma Flare"),
|
|
60
|
+
("flare", "\u2738", "\\u2738", "Eight-Point Flare Explosion"),
|
|
61
|
+
("sparkles", "\u2728", "\\u2728", "Magic Twinkling Energy Sparks"),
|
|
62
|
+
("octo-flame", "\uf490", "\\uF490", "GitHub Octicon Energetic Fire Flame"),
|
|
63
|
+
("plasma-fire", "\U000f0238", "\\U000F0238", "Curved Hot Plasma Flame"),
|
|
64
|
+
("overdrive", "\U000f04c5", "\\U000F04C5", "Tachometer Needle in Red / Overdrive"),
|
|
65
|
+
("wave-pulse", "\u219d", "\\u219D", "Waveform Oscillator Energy Arrow"),
|
|
66
|
+
("squiggle", "\u21dd", "\\u21DD", "Pulse Wave Kinetic Squiggle Arrow"),
|
|
67
|
+
],
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
ALL_PRESETS: list[tuple[str, str, str, str]] = [
|
|
71
|
+
item for items in CATEGORIES.values() for item in items
|
|
72
|
+
]
|
|
73
|
+
|
|
74
|
+
CHARACTER_PALETTE: dict[str, list[tuple[str, str, str]]] = {
|
|
75
|
+
"Powerline & Dividers": [
|
|
76
|
+
("\ue0b0", "E0B0", "Triangle"),
|
|
77
|
+
("\ue0b1", "E0B1", "Thin Tri"),
|
|
78
|
+
("\ue0b4", "E0B4", "Bubble"),
|
|
79
|
+
("\ue0b5", "E0B5", "Thin Bub"),
|
|
80
|
+
("\ue0bc", "E0BC", "Slant Lo"),
|
|
81
|
+
("\ue0be", "E0BE", "Slant Up"),
|
|
82
|
+
("\ue0c0", "E0C0", "Flame"),
|
|
83
|
+
("\ue0c1", "E0C1", "Thin Flam"),
|
|
84
|
+
("\ue0c4", "E0C4", "Pixel"),
|
|
85
|
+
("\ue0c6", "E0C6", "Sm Pixel"),
|
|
86
|
+
("\ue0ca", "E0CA", "Wave"),
|
|
87
|
+
("\ue0cc", "E0CC", "Hexagon"),
|
|
88
|
+
("\ue0c8", "E0C8", "Ice Notch"),
|
|
89
|
+
("\ue0cd", "E0CD", "Thin Hex"),
|
|
90
|
+
("\ue0d4", "E0D4", "Sharp Slnt"),
|
|
91
|
+
("\ue0d2", "E0D2", "Trapezoid"),
|
|
92
|
+
],
|
|
93
|
+
"Chevrons, Pointers & Arrows": [
|
|
94
|
+
("\u00bb", "00BB", "Dbl Chevr"),
|
|
95
|
+
("\u203a", "203A", "Sgl Chevr"),
|
|
96
|
+
("\u2192", "2192", "Thin Arrow"),
|
|
97
|
+
("\u279c", "279C", "Hvy Arrow"),
|
|
98
|
+
("\u27a4", "27A4", "Arrowhead"),
|
|
99
|
+
("\u25b6", "25B6", "Play Tri"),
|
|
100
|
+
("\u25b8", "25B8", "Sm Tri"),
|
|
101
|
+
("\u25ba", "25BA", "Point Tri"),
|
|
102
|
+
("\uf105", "F105", "FA Angle"),
|
|
103
|
+
("\uf054", "F054", "FA Chevr"),
|
|
104
|
+
("\uf061", "F061", "FA Arrow"),
|
|
105
|
+
("\uf0da", "F0DA", "FA Caret"),
|
|
106
|
+
("\uf460", "F460", "Oct Chevr"),
|
|
107
|
+
("\uf432", "F432", "Oct Tri"),
|
|
108
|
+
("\u00ab", "00AB", "Left Chevr"),
|
|
109
|
+
("\u25c0", "25C0", "Left Tri"),
|
|
110
|
+
],
|
|
111
|
+
"Geometric & Block Dividers": [
|
|
112
|
+
("\u2571", "2571", "Diag Slash"),
|
|
113
|
+
("\u2572", "2572", "Backslash"),
|
|
114
|
+
("\u2502", "2502", "Vert Bar"),
|
|
115
|
+
("\u2503", "2503", "Heavy Bar"),
|
|
116
|
+
("\u258c", "258C", "Half Block"),
|
|
117
|
+
("\u2590", "2590", "R HalfBlk"),
|
|
118
|
+
("\u2588", "2588", "Full Block"),
|
|
119
|
+
("\u2591", "2591", "Light Shade"),
|
|
120
|
+
("\u25c6", "25C6", "Diamond"),
|
|
121
|
+
("\u25c7", "25C7", "White Diam"),
|
|
122
|
+
("\u25cf", "25CF", "Circle"),
|
|
123
|
+
("\u25cb", "25CB", "White Circ"),
|
|
124
|
+
],
|
|
125
|
+
"Electricity, Sparks & Kinetic": [
|
|
126
|
+
("\u26a1", "26A1", "Zap Bolt"),
|
|
127
|
+
("\uf0e7", "F0E7", "FA Bolt"),
|
|
128
|
+
("\u21af", "21AF", "Thunder"),
|
|
129
|
+
("\U000f140b", "F140B", "MDI Flash"),
|
|
130
|
+
("\U000f140c", "F140C", "Wire Flash"),
|
|
131
|
+
("\u2726", "2726", "Sparkle"),
|
|
132
|
+
("\u2727", "2727", "Hollow Spark"),
|
|
133
|
+
("\u2728", "2728", "Sparkles"),
|
|
134
|
+
("\u2739", "2739", "12-Pt Burst"),
|
|
135
|
+
("\u2738", "2738", "8-Pt Flare"),
|
|
136
|
+
("\u2735", "2735", "Pinwheel"),
|
|
137
|
+
("\uf490", "F490", "Octo Flame"),
|
|
138
|
+
("\U000f0238", "F0238", "Plasma Fire"),
|
|
139
|
+
("\U000f04c5", "F04C5", "Overdrive"),
|
|
140
|
+
("\u219d", "219D", "Wave Zap"),
|
|
141
|
+
("\u21dd", "21DD", "Squiggle"),
|
|
142
|
+
],
|
|
143
|
+
"Nerd Font Emblems & Icons": [
|
|
144
|
+
("\u2605", "2605", "Star"),
|
|
145
|
+
("\uf135", "F135", "Rocket"),
|
|
146
|
+
("\uf023", "F023", "Lock"),
|
|
147
|
+
("\ue725", "E725", "Git Branch"),
|
|
148
|
+
("\uf418", "F418", "Oct Branch"),
|
|
149
|
+
("\uf308", "F308", "Docker"),
|
|
150
|
+
("\U000f00fe", "F00FE", "Kubernetes"),
|
|
151
|
+
("\U000f0062", "F0062", "Terraform"),
|
|
152
|
+
("\ue271", "E271", "Terminal"),
|
|
153
|
+
("\u2665", "2665", "Heart"),
|
|
154
|
+
("\u2714", "2714", "Checkmark"),
|
|
155
|
+
("\uf017", "F017", "Clock"),
|
|
156
|
+
],
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
def glyph_to_code(glyph: str) -> str:
|
|
161
|
+
"""Encode a Unicode character into a Bash/printf-compatible escape (`\\uXXXX` or `\\UXXXXXXXX`)."""
|
|
162
|
+
if not glyph:
|
|
163
|
+
return "\\uE0B0"
|
|
164
|
+
if len(glyph) == 1:
|
|
165
|
+
cp = ord(glyph)
|
|
166
|
+
if cp > 0xFFFF:
|
|
167
|
+
return f"\\U{cp:08X}"
|
|
168
|
+
if cp > 127:
|
|
169
|
+
return f"\\u{cp:04X}"
|
|
170
|
+
return glyph
|
|
171
|
+
return glyph
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
def parse_separator_value(raw_val: str) -> tuple[str, str]:
|
|
175
|
+
"""Parse a separator value from `synth-shell-prompt.config` into `(glyph, code_str)`."""
|
|
176
|
+
s = raw_val.strip()
|
|
177
|
+
if s.startswith("$'") and s.endswith("'"):
|
|
178
|
+
s = s[2:-1]
|
|
179
|
+
elif (s.startswith('"') and s.endswith('"')) or (s.startswith("'") and s.endswith("'")):
|
|
180
|
+
s = s[1:-1]
|
|
181
|
+
s = s.strip()
|
|
182
|
+
|
|
183
|
+
m_hex = re.match(r"^\\([uU])([0-9a-fA-F]{4,8})$", s)
|
|
184
|
+
if m_hex:
|
|
185
|
+
try:
|
|
186
|
+
cp = int(m_hex.group(2), 16)
|
|
187
|
+
glyph = chr(cp)
|
|
188
|
+
code = f"\\U{cp:08X}" if cp > 0xFFFF else f"\\u{cp:04X}"
|
|
189
|
+
return glyph, code
|
|
190
|
+
except ValueError:
|
|
191
|
+
pass
|
|
192
|
+
|
|
193
|
+
if len(s) == 1:
|
|
194
|
+
return s, glyph_to_code(s)
|
|
195
|
+
return s, s
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
def parse_custom_char(input_str: str) -> tuple[str, str]:
|
|
199
|
+
"""Parse user input (`E0B4`, `\\uE0B4`, `U+E0B4`, `0xE0B4`, or literal glyph) into `(glyph, code_str)`."""
|
|
200
|
+
s = input_str.strip().strip('"').strip("'")
|
|
201
|
+
hex_match = re.match(r"^(?:\\u|\\U|u\+|0x)?([0-9a-fA-F]{4,8})$", s, re.IGNORECASE)
|
|
202
|
+
if hex_match:
|
|
203
|
+
cp = int(hex_match.group(1), 16)
|
|
204
|
+
if 0 < cp <= 0x10FFFF:
|
|
205
|
+
glyph = chr(cp)
|
|
206
|
+
code = f"\\U{cp:08X}" if cp > 0xFFFF else f"\\u{cp:04X}"
|
|
207
|
+
return glyph, code
|
|
208
|
+
if len(s) == 1:
|
|
209
|
+
return s, glyph_to_code(s)
|
|
210
|
+
return s, s
|
|
211
|
+
|
|
212
|
+
|
|
213
|
+
def find_preset(query: str | int) -> tuple[str, str, str, str] | None:
|
|
214
|
+
"""Find a curated preset separator by 1-based index, key slug, or glyph."""
|
|
215
|
+
q = str(query).strip().lower()
|
|
216
|
+
if not q:
|
|
217
|
+
return None
|
|
218
|
+
if q.isdigit():
|
|
219
|
+
idx = int(q)
|
|
220
|
+
if 1 <= idx <= len(ALL_PRESETS):
|
|
221
|
+
return ALL_PRESETS[idx - 1]
|
|
222
|
+
return None
|
|
223
|
+
for key, glyph, code, desc in ALL_PRESETS:
|
|
224
|
+
if q in (key, key.replace("-", ""), glyph.lower(), desc.lower()):
|
|
225
|
+
return key, glyph, code, desc
|
|
226
|
+
for key, glyph, code, desc in ALL_PRESETS:
|
|
227
|
+
if q in key or q in desc.lower():
|
|
228
|
+
return key, glyph, code, desc
|
|
229
|
+
return None
|
|
230
|
+
|
|
231
|
+
|
|
232
|
+
def find_palette_char(query: str) -> tuple[str, str, str] | None:
|
|
233
|
+
"""Find a character in the 60+ glyph palette by hex code, short label, or glyph."""
|
|
234
|
+
q = query.strip().lower()
|
|
235
|
+
if not q:
|
|
236
|
+
return None
|
|
237
|
+
for items in CHARACTER_PALETTE.values():
|
|
238
|
+
for glyph, hex_code, desc in items:
|
|
239
|
+
code = f"\\U{int(hex_code, 16):08X}" if len(hex_code) > 4 else f"\\u{hex_code.upper()}"
|
|
240
|
+
if q in (
|
|
241
|
+
glyph.lower(),
|
|
242
|
+
hex_code.lower(),
|
|
243
|
+
desc.lower(),
|
|
244
|
+
desc.lower().replace(" ", ""),
|
|
245
|
+
code.lower(),
|
|
246
|
+
f"u+{hex_code.lower()}",
|
|
247
|
+
f"0x{hex_code.lower()}",
|
|
248
|
+
):
|
|
249
|
+
return glyph, code, desc
|
|
250
|
+
return None
|
|
251
|
+
|
|
252
|
+
|
|
253
|
+
def get_separator_key(glyph: str) -> str:
|
|
254
|
+
"""Return the preset key matching `glyph`, or `'custom'`."""
|
|
255
|
+
for key, g, _, _ in ALL_PRESETS:
|
|
256
|
+
if g == glyph:
|
|
257
|
+
return key
|
|
258
|
+
return "custom"
|
|
259
|
+
|
|
260
|
+
|
|
261
|
+
def resolve_separator_input(user_input: str) -> tuple[str, str, str]:
|
|
262
|
+
"""Resolve any preset index/name, palette label, hex code, or literal glyph into `(glyph, code_str, label)`."""
|
|
263
|
+
preset = find_preset(user_input)
|
|
264
|
+
if preset:
|
|
265
|
+
return preset[1], preset[2], f"{preset[0]} ({preset[3]})"
|
|
266
|
+
pal = find_palette_char(user_input)
|
|
267
|
+
if pal:
|
|
268
|
+
return pal[0], pal[1], pal[2]
|
|
269
|
+
glyph, code = parse_custom_char(user_input)
|
|
270
|
+
return glyph, code, "Custom"
|
|
271
|
+
|
|
272
|
+
|
|
273
|
+
def format_separator_assignment(var_name: str, code_str: str) -> str:
|
|
274
|
+
"""Format a safe Bash config line (`separator_char="\\uE0B4"`)."""
|
|
275
|
+
if re.match(r"^\\[uU][0-9A-Fa-f]{4,8}$", code_str):
|
|
276
|
+
return f'{var_name}="{code_str}"'
|
|
277
|
+
escaped = code_str.replace("\\", "\\\\").replace('"', '\\"').replace("$", "\\$").replace("`", "\\`")
|
|
278
|
+
return f'{var_name}="{escaped}"'
|
|
279
|
+
|
|
280
|
+
|
|
281
|
+
def serialize_separators_for_web() -> dict[str, object]:
|
|
282
|
+
"""Serialize all separator presets and palette glyphs for Web Studio."""
|
|
283
|
+
categories_out: list[dict[str, object]] = []
|
|
284
|
+
idx_counter = 1
|
|
285
|
+
for cat_name, items in CATEGORIES.items():
|
|
286
|
+
cat_items = []
|
|
287
|
+
for key, glyph, code, desc in items:
|
|
288
|
+
cat_items.append(
|
|
289
|
+
{
|
|
290
|
+
"id": idx_counter,
|
|
291
|
+
"key": key,
|
|
292
|
+
"glyph": glyph,
|
|
293
|
+
"code": code,
|
|
294
|
+
"description": desc,
|
|
295
|
+
}
|
|
296
|
+
)
|
|
297
|
+
idx_counter += 1
|
|
298
|
+
categories_out.append({"name": cat_name, "items": cat_items})
|
|
299
|
+
|
|
300
|
+
palette_out = [
|
|
301
|
+
{
|
|
302
|
+
"group": group_name,
|
|
303
|
+
"items": [
|
|
304
|
+
{
|
|
305
|
+
"glyph": glyph,
|
|
306
|
+
"hex": hex_code,
|
|
307
|
+
"code": f"\\U{int(hex_code, 16):08X}" if len(hex_code) > 4 else f"\\u{hex_code.upper()}",
|
|
308
|
+
"label": label,
|
|
309
|
+
}
|
|
310
|
+
for glyph, hex_code, label in items
|
|
311
|
+
],
|
|
312
|
+
}
|
|
313
|
+
for group_name, items in CHARACTER_PALETTE.items()
|
|
314
|
+
]
|
|
315
|
+
|
|
316
|
+
return {
|
|
317
|
+
"total_presets": len(ALL_PRESETS),
|
|
318
|
+
"categories": categories_out,
|
|
319
|
+
"palette": palette_out,
|
|
320
|
+
}
|