gjs-typelib-installer
    Preparing search index...

    Function findTerminalCommand

    • Finds a terminal emulator to run commands in. Checks for GNOME Console (kgx), gnome-terminal, and xdg-terminal-exec in order.

      Parameters

      • cancellable: Cancellable | null = null

        Optional cancellable for aborting the operation.

      Returns Promise<TerminalCommandResolver | null>

      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');
      }