Optional cancellable for aborting the operation.
A function that generates the command line, or null if no suitable terminal is found.
const terminal = await findTerminalCommand();
if (terminal) {
const argv = terminal(['echo', 'Hello, world!']);
const [, pid] = GLib.spawn_async(null, argv, null, GLib.SpawnFlags.DEFAULT, null);
GLib.spawn_close_pid(/** @type {GLib.Pid} */ (pid));
} else {
printerr('No terminal emulators found');
}
Finds a terminal emulator to run commands in. Checks for GNOME Console (kgx), gnome-terminal, and xdg-terminal-exec in order.