diff --git a/hyfetch/main.py b/hyfetch/main.py index 88bc20c4..bb35b368 100755 --- a/hyfetch/main.py +++ b/hyfetch/main.py @@ -356,7 +356,7 @@ def run(): parser.add_argument('-C', '--config-file', dest='config_file', default=CONFIG_PATH, help=f'Use another config file') parser.add_argument('-p', '--preset', help=f'Use preset', choices=PRESETS.keys()) parser.add_argument('-m', '--mode', help=f'Color mode', choices=['8bit', 'rgb']) - parser.add_argument('-b', '--backend', help=f'Choose a *fetch backend', choices=['neofetch', 'fastfetch']) + parser.add_argument('-b', '--backend', help=f'Choose a *fetch backend', choices=['neofetch', 'fastfetch', 'fastfetch-old']) parser.add_argument('--c-scale', dest='scale', help=f'Lighten colors by a multiplier', type=float) parser.add_argument('--c-set-l', dest='light', help=f'Set lightness value of the colors', type=float) parser.add_argument('-V', '--version', dest='version', action='store_true', help=f'Check version') diff --git a/hyfetch/neofetch_util.py b/hyfetch/neofetch_util.py index 31a95915..1046297c 100644 --- a/hyfetch/neofetch_util.py +++ b/hyfetch/neofetch_util.py @@ -265,6 +265,8 @@ def run(preset: ColorProfile, alignment: ColorAlignment, backend: BackendLiteral return run_neofetch(preset, alignment) if backend == "fastfetch": return run_fastfetch(preset, alignment) + if backend == "fastfetch-old": + return run_fastfetch(preset, alignment, legacy=True) def run_neofetch(preset: ColorProfile, alignment: ColorAlignment): @@ -290,12 +292,13 @@ def run_neofetch(preset: ColorProfile, alignment: ColorAlignment): run_neofetch_cmd(f'--ascii --source {path.absolute()} --ascii-colors') -def run_fastfetch(preset: ColorProfile, alignment: ColorAlignment): +def run_fastfetch(preset: ColorProfile, alignment: ColorAlignment, legacy: bool = False): """ Run neofetch with colors :param preset: Color palette :param alignment: Color alignment settings + :param legacy: Set true when using fastfetch < 1.8.0 """ asc = get_distro_ascii() asc = alignment.recolor_ascii(asc, preset) @@ -307,7 +310,9 @@ def run_fastfetch(preset: ColorProfile, alignment: ColorAlignment): path.write_text(asc) # Call fastfetch with the temp file - subprocess.run(['fastfetch', '--file-raw', path.absolute()]) + proc = subprocess.run(['fastfetch', '--raw' if legacy else '--file-raw', path.absolute()]) + if proc.returncode == 144: + printc("&6Error code 144 detected: Please upgrade fastfetch to >=1.8.0 or use the 'fastfetch-old' backend") def get_fore_back(distro: str | None = None) -> tuple[int, int] | None: