[+] Get custom distro ascii

This commit is contained in:
Azalea (on HyDEV-Daisy) 2022-06-19 15:18:34 -04:00
parent 9a77c39170
commit 002697b49a
2 changed files with 23 additions and 3 deletions

View file

@ -32,10 +32,17 @@ def get_distro_ascii() -> str:
return check_output([get_command_path(), "print_ascii"]).decode().strip()
def run_neofetch(preset: ColorProfile, mode: AnsiMode):
# Get existing ascii
asc = get_distro_ascii()
def get_custom_distro_ascii(distro: str) -> str:
"""
Get the distro ascii of a specific distro
:return: Distro ascii
"""
os.environ['CUSTOM_DISTRO'] = distro
return check_output([get_command_path(), "print_custom_ascii"]).decode().strip()
def replace_colors(asc: str, preset: ColorProfile, mode: AnsiMode):
# Remove existing colors
asc = re.sub('\\${.*?}', '', asc)
@ -44,6 +51,12 @@ def run_neofetch(preset: ColorProfile, mode: AnsiMode):
colors = preset.with_length(len(lines))
asc = '\n'.join([colors[i].to_ansi(mode) + l for i, l in enumerate(lines)])
return asc, lines
def run_neofetch(preset: ColorProfile, mode: AnsiMode):
asc, lines = replace_colors(get_distro_ascii(), preset, mode)
# Write temp file
with TemporaryDirectory() as tmp_dir:
tmp_dir = Path(tmp_dir)

View file

@ -11607,4 +11607,11 @@ get_print_ascii() {
echo "$ascii_data"
}
get_print_custom_ascii() {
distro="$CUSTOM_DISTRO"
ascii_distro=$distro
get_distro_ascii
echo "$ascii_data"
}
main "$@"