From 881534987b2b42176193fceb08c0a97251c506e1 Mon Sep 17 00:00:00 2001 From: "Azalea (on HyDEV-Daisy)" Date: Mon, 5 Sep 2022 17:40:13 -0400 Subject: [PATCH] [F] Fix backslashes escape in HyFetch https://github.com/hykilpikonna/hyfetch/issues/19 --- hyfetch/neofetch_util.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/hyfetch/neofetch_util.py b/hyfetch/neofetch_util.py index a742d684..c7292027 100644 --- a/hyfetch/neofetch_util.py +++ b/hyfetch/neofetch_util.py @@ -238,7 +238,12 @@ def get_distro_ascii(distro: str | None = None) -> str: os.environ['CUSTOM_DISTRO'] = distro 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(): @@ -256,6 +261,9 @@ def run_neofetch(preset: ColorProfile, alignment: ColorAlignment): w, h = ascii_size(asc) asc = alignment.recolor_ascii(asc, preset) + # Escape backslashes here because backslashes are escaped in neofetch for printf + asc = asc.replace('\\', '\\\\') + # Write temp file with TemporaryDirectory() as tmp_dir: tmp_dir = Path(tmp_dir)