diff --git a/data/hu.kramo.Cartridges.gschema.xml.in b/data/hu.kramo.Cartridges.gschema.xml.in
index c64dc02..3da3a37 100644
--- a/data/hu.kramo.Cartridges.gschema.xml.in
+++ b/data/hu.kramo.Cartridges.gschema.xml.in
@@ -89,7 +89,7 @@
true
-
+
"xdg-terminal-exec"
@@ -141,5 +141,8 @@
"[]"
+
+ false
+
diff --git a/src/main.py b/src/main.py
index 8a89973..c04aae5 100644
--- a/src/main.py
+++ b/src/main.py
@@ -20,6 +20,8 @@
import json
import lzma
import os
+import shlex
+import subprocess
import sys
from typing import Any, Optional
@@ -73,6 +75,10 @@ class CartridgesApplication(Adw.Application):
if os.name == "nt":
migrate_files_v1_to_v2()
+ else:
+ if not shared.state_schema.get_boolean("terminal-check-done"):
+ self.check_desktop_terminals()
+ shared.state_schema.set_boolean("terminal-check-done", True)
# Set fallback icon-name
Gtk.Window.set_default_icon_name(shared.APP_ID)
@@ -143,6 +149,22 @@ class CartridgesApplication(Adw.Application):
self.win.present()
+ def check_desktop_terminals(self) -> None:
+ """Look for an installed terminal for desktop entries"""
+ terminals = ("xdg-terminal-exec", "kgx", "gnome-terminal", "konsole", "xterm")
+
+ for index, command in enumerate(terminals):
+ command = f"type {command} &> /dev/null"
+ if os.getenv("FLATPAK_ID") == shared.APP_ID:
+ command = "flatpak-spawn --host /bin/sh -c " + shlex.quote(command)
+
+ try:
+ subprocess.run(command, shell=True, check=True)
+ shared.schema.set_enum("desktop-terminal", index + 1)
+ return
+ except subprocess.CalledProcessError:
+ pass
+
def load_games_from_disk(self) -> None:
if shared.games_dir.is_dir():
for game_file in shared.games_dir.iterdir():