From 7001d873b9252361189f81a12629c9fcbffee3f2 Mon Sep 17 00:00:00 2001 From: Hykilpikonna Date: Sat, 20 Aug 2022 20:52:21 -0400 Subject: [PATCH] [+] Run MinTTY from cmd.exe --- hyfetch/main.py | 1 + hyfetch/neofetch_util.py | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/hyfetch/main.py b/hyfetch/main.py index cfa6b07a..b3e04fcf 100755 --- a/hyfetch/main.py +++ b/hyfetch/main.py @@ -346,6 +346,7 @@ def run(): # Ensure git bash for windows ensure_git_bash() + check_windows_cmd() # Test distro ascii art if args.test_distro: diff --git a/hyfetch/neofetch_util.py b/hyfetch/neofetch_util.py index 4974399b..6a6269c0 100644 --- a/hyfetch/neofetch_util.py +++ b/hyfetch/neofetch_util.py @@ -179,6 +179,19 @@ def ensure_git_bash() -> Path: print('Done!') return path / r'bin\bash.exe' + +def check_windows_cmd(): + """ + Check if this script is running under cmd.exe. If so, launch an external window with git bash + since cmd doesn't support RGB colors. + """ + if psutil.Process(os.getppid()).name().lower().strip() == 'cmd.exe': + print("cmd.exe doesn't support RGB colors, restarting in MinTTY...") + cmd = f'"{ensure_git_bash().parent.parent / "usr/bin/mintty.exe"}" -s 110,40 -e python -m hyfetch --ask-exit' + os.system(cmd) + exit() + + def run_command(args: str, pipe: bool = False) -> str | None: """ Run neofetch command