get default terminal (thanks diablosat)

This commit is contained in:
Andrew
2025-11-02 03:42:42 +03:00
parent b30982f9e8
commit b93d02faf3
2 changed files with 51 additions and 5 deletions

View File

@@ -11,7 +11,7 @@ from src.runexethread import RunExeThread
from src.killaethread import KillAEThread
from src.removeaethread import RemoveAEThread
from src.utils import (
check_aegnux_tip_marked, get_wine_bin_path_env,
check_aegnux_tip_marked, get_default_terminal, get_wine_bin_path_env,
get_cep_dir, get_ae_plugins_dir, get_wineprefix_dir,
check_aegnux_installed, mark_aegnux_tip_as_shown, get_ae_install_dir, get_aegnux_installation_dir
)
@@ -248,10 +248,11 @@ class MainWindow(MainWindowUI):
env['WINEPREFIX'] = get_wineprefix_dir()
env['PATH'] = get_wine_bin_path_env('/usr/bin')
process = subprocess.Popen(
['./bin/kitty/bin/kitty', 'bash'],
env=env
)
try:
terminal = get_default_terminal()
subprocess.Popen([terminal, "bash"], env=env)
except RuntimeError as e:
print("[CRITICAL ERROR]:", e)
@Slot()
def run_command_ctrl_q(self):

View File

@@ -148,7 +148,52 @@ def get_wine_bin_path_env(old_path: str | None):
old_path = old_path if old_path is not None else os.getenv('PATH')
return f'{get_wine_runner_dir().as_posix()}/bin:{old_path}'
def get_default_terminal() -> str:
DEFAULT_ENVS = ["TERMINAL", "TERM_PROGRAM"]
TERMINALS = [
"konsole",
"kitty",
"alacritty",
"gnome-terminal",
"xfce4-terminal",
"terminator",
"lxterminal",
"tilix",
"st",
"mate-terminal",
"xterm",
"urxvt",
"deepin-terminal",
"sakura",
"tilda",
"guake",
"hyper",
"eterm",
"rxvt",
"lxterm",
"cosmic-terminal",
]
candidates = (
shutil.which(os.environ.get(var)) for var in DEFAULT_ENVS if os.environ.get(var)
)
# Debian/Ubuntu
alt = "/etc/alternatives/x-terminal-emulator"
if os.path.exists(alt):
candidates = (shutil.which(os.readlink(alt)), *candidates)
# Popular terminals
candidates = (*candidates, *(shutil.which(term) for term in TERMINALS))
terminal = next((t for t in candidates if t), None)
if terminal:
return terminal
raise RuntimeError(
"Your terminal was not found or is not supported.\n"
"Install one of the following: " + ", ".join(TERMINALS)
)
def get_aegnux_tip_marked_flag_path():
hades = get_aegnux_installation_dir()