Bläddra i källkod

[+] Get custom distro ascii

Azalea (on HyDEV-Daisy) 3 år sedan
förälder
incheckning
002697b49a
2 ändrade filer med 23 tillägg och 3 borttagningar
  1. 16 3
      hyfetch/neofetch_util.py
  2. 7 0
      neofetch

+ 16 - 3
hyfetch/neofetch_util.py

@@ -32,10 +32,17 @@ def get_distro_ascii() -> str:
     return check_output([get_command_path(), "print_ascii"]).decode().strip()
     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
     # Remove existing colors
     asc = re.sub('\\${.*?}', '', asc)
     asc = re.sub('\\${.*?}', '', asc)
 
 
@@ -44,6 +51,12 @@ def run_neofetch(preset: ColorProfile, mode: AnsiMode):
     colors = preset.with_length(len(lines))
     colors = preset.with_length(len(lines))
     asc = '\n'.join([colors[i].to_ansi(mode) + l for i, l in enumerate(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
     # Write temp file
     with TemporaryDirectory() as tmp_dir:
     with TemporaryDirectory() as tmp_dir:
         tmp_dir = Path(tmp_dir)
         tmp_dir = Path(tmp_dir)

+ 7 - 0
neofetch

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