[+] Add custom ascii file option, closes #104
This commit is contained in:
parent
365ed5a91f
commit
8c5905c858
2 changed files with 13 additions and 17 deletions
|
@ -320,7 +320,9 @@ def run():
|
|||
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')
|
||||
parser.add_argument('--debug', action='store_true', help=f'Debug mode')
|
||||
|
||||
parser.add_argument('--distro', '--test-distro', dest='distro', help=f'Test for a specific distro')
|
||||
parser.add_argument('--ascii-file', help='Use a specific file for the ascii art')
|
||||
|
||||
# Hidden debug arguments
|
||||
# --test-print: Print the ascii distro and exit
|
||||
|
@ -384,7 +386,9 @@ def run():
|
|||
|
||||
# Run
|
||||
try:
|
||||
neofetch_util.run(preset, config.color_align, config.backend)
|
||||
asc = get_distro_ascii() if not args.ascii_file else Path(args.ascii_file).read_text("utf-8")
|
||||
asc = config.color_align.recolor_ascii(asc, preset)
|
||||
neofetch_util.run(asc, config.backend)
|
||||
except Exception as e:
|
||||
print(f'Error: {e}')
|
||||
traceback.print_exc()
|
||||
|
|
|
@ -336,25 +336,21 @@ def get_distro_name():
|
|||
return run_neofetch_cmd('ascii_distro_name', True)
|
||||
|
||||
|
||||
def run(preset: ColorProfile, alignment: ColorAlignment, backend: BackendLiteral):
|
||||
def run(asc: str, backend: BackendLiteral):
|
||||
if backend == "neofetch":
|
||||
return run_neofetch(preset, alignment)
|
||||
return run_neofetch(asc)
|
||||
if backend == "fastfetch":
|
||||
return run_fastfetch(preset, alignment)
|
||||
return run_fastfetch(asc)
|
||||
if backend == "fastfetch-old":
|
||||
return run_fastfetch(preset, alignment, legacy=True)
|
||||
return run_fastfetch(asc, legacy=True)
|
||||
|
||||
|
||||
def run_neofetch(preset: ColorProfile, alignment: ColorAlignment):
|
||||
def run_neofetch(asc: str):
|
||||
"""
|
||||
Run neofetch with colors
|
||||
|
||||
:param preset: Color palette
|
||||
:param alignment: Color alignment settings
|
||||
:param asc: Ascii art
|
||||
"""
|
||||
asc = get_distro_ascii()
|
||||
asc = alignment.recolor_ascii(asc, preset)
|
||||
|
||||
# Escape backslashes here because backslashes are escaped in neofetch for printf
|
||||
asc = asc.replace('\\', '\\\\')
|
||||
|
||||
|
@ -368,17 +364,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, legacy: bool = False):
|
||||
def run_fastfetch(asc: str, legacy: bool = False):
|
||||
"""
|
||||
Run neofetch with colors
|
||||
|
||||
:param preset: Color palette
|
||||
:param alignment: Color alignment settings
|
||||
:param asc: Ascii art
|
||||
:param legacy: Set true when using fastfetch < 1.8.0
|
||||
"""
|
||||
asc = get_distro_ascii()
|
||||
asc = alignment.recolor_ascii(asc, preset)
|
||||
|
||||
# Write temp file
|
||||
with TemporaryDirectory() as tmp_dir:
|
||||
tmp_dir = Path(tmp_dir)
|
||||
|
|
Loading…
Reference in a new issue