Experimental support for launching from gui linux
This commit is contained in:
parent
55a5e6b9b3
commit
92cce93edd
1 changed files with 28 additions and 0 deletions
|
|
@ -712,7 +712,35 @@ def main():
|
||||||
pass
|
pass
|
||||||
pygame.mixer.quit()
|
pygame.mixer.quit()
|
||||||
|
|
||||||
|
def has_terminal():
|
||||||
|
return sys.stdout.isatty() and sys.stdin.isatty()
|
||||||
|
|
||||||
|
def relaunch_in_terminal():
|
||||||
|
# Detect the current folder and script/binary path
|
||||||
|
script = os.path.abspath(sys.argv[0])
|
||||||
|
|
||||||
|
# Choose a terminal emulator (Konsole, GNOME Terminal, xterm)
|
||||||
|
terminals = [
|
||||||
|
["konsole", "--hold", "-e"],
|
||||||
|
["gnome-terminal", "--", "bash", "-c"],
|
||||||
|
["xterm", "-hold", "-e"]
|
||||||
|
]
|
||||||
|
|
||||||
|
for term in terminals:
|
||||||
|
try:
|
||||||
|
subprocess.Popen(term + [script] + sys.argv[1:])
|
||||||
|
sys.exit(0) # exit the current GUI-launched process
|
||||||
|
except FileNotFoundError:
|
||||||
|
continue
|
||||||
|
|
||||||
|
# If no terminal found, just print a warning
|
||||||
|
print("No terminal emulator found. Please run from a terminal.")
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
if (os.name != "nt"):
|
||||||
|
if not has_terminal():
|
||||||
|
relaunch_in_terminal()
|
||||||
|
|
||||||
lock_fd, lock_path = acquire_single_instance("q3a_launcher.lock")
|
lock_fd, lock_path = acquire_single_instance("q3a_launcher.lock")
|
||||||
if lock_fd is None:
|
if lock_fd is None:
|
||||||
print("Another instance is already running.")
|
print("Another instance is already running.")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue