mirror of
https://github.com/relativemodder/aegnux.git
synced 2025-12-14 07:29:39 +05:00
get default terminal (thanks diablosat)
This commit is contained in:
@@ -11,7 +11,7 @@ from src.runexethread import RunExeThread
|
|||||||
from src.killaethread import KillAEThread
|
from src.killaethread import KillAEThread
|
||||||
from src.removeaethread import RemoveAEThread
|
from src.removeaethread import RemoveAEThread
|
||||||
from src.utils import (
|
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,
|
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
|
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['WINEPREFIX'] = get_wineprefix_dir()
|
||||||
env['PATH'] = get_wine_bin_path_env('/usr/bin')
|
env['PATH'] = get_wine_bin_path_env('/usr/bin')
|
||||||
|
|
||||||
process = subprocess.Popen(
|
try:
|
||||||
['./bin/kitty/bin/kitty', 'bash'],
|
terminal = get_default_terminal()
|
||||||
env=env
|
subprocess.Popen([terminal, "bash"], env=env)
|
||||||
)
|
except RuntimeError as e:
|
||||||
|
print("[CRITICAL ERROR]:", e)
|
||||||
|
|
||||||
@Slot()
|
@Slot()
|
||||||
def run_command_ctrl_q(self):
|
def run_command_ctrl_q(self):
|
||||||
|
|||||||
45
src/utils.py
45
src/utils.py
@@ -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')
|
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}'
|
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():
|
def get_aegnux_tip_marked_flag_path():
|
||||||
hades = get_aegnux_installation_dir()
|
hades = get_aegnux_installation_dir()
|
||||||
|
|||||||
Reference in New Issue
Block a user