[F] Fix backslashes escape in HyFetch

https://github.com/hykilpikonna/hyfetch/issues/19
This commit is contained in:
Azalea (on HyDEV-Daisy) 2022-09-05 17:40:13 -04:00
parent f54c45fbd0
commit 881534987b
No known key found for this signature in database
GPG key ID: E289FAC0DA92DD2B

View file

@ -238,7 +238,12 @@ def get_distro_ascii(distro: str | None = None) -> str:
os.environ['CUSTOM_DISTRO'] = distro os.environ['CUSTOM_DISTRO'] = distro
cmd = 'print_custom_ascii' cmd = 'print_custom_ascii'
return normalize_ascii(run_command(cmd, True)) asc = run_command(cmd, True)
# Unescape backslashes here because backslashes are escaped in neofetch for printf
asc = asc.replace('\\\\', '\\')
return normalize_ascii(asc)
def get_distro_name(): def get_distro_name():
@ -256,6 +261,9 @@ def run_neofetch(preset: ColorProfile, alignment: ColorAlignment):
w, h = ascii_size(asc) w, h = ascii_size(asc)
asc = alignment.recolor_ascii(asc, preset) asc = alignment.recolor_ascii(asc, preset)
# Escape backslashes here because backslashes are escaped in neofetch for printf
asc = asc.replace('\\', '\\\\')
# Write temp file # Write temp file
with TemporaryDirectory() as tmp_dir: with TemporaryDirectory() as tmp_dir:
tmp_dir = Path(tmp_dir) tmp_dir = Path(tmp_dir)