'Starting the default terminal on Linux

Tell me, please, is it possible to call the Linux Terminal, which is installed by default, in some way (method)?

Now, I run the process in the xfce4-terminal terminal, specifying this terminal and the arguments to it:

QProcess up;
QString cArg;
 
cArg="/tmp/cp.py -y " + ye;
up.start("xfce4-terminal", QStringList()<< "--geometry=120x40" << "--command" << "python3 "+ cArg << "-H");
up.waitForFinished();
up.close();


Solution 1:[1]

You can use i3's sensible-terminal script.

https://github.com/i3/i3/blob/next/i3-sensible-terminal

While it has been made for i3, if you read the source you'll see it's very simple and doesn't rely on it, so feel free to use this within whatever desktop environment you want.

Though if you don't use i3 you may want to remove the last line (which isn't that important as you are unlikely to have no terminal installed at all).

Explanations

It proceeds by getting, in this order:

  • A terminal you may have defined in the non-standard $TERMINAL environment variable
  • x-terminal-emulator which is a similar utility for Debian only
  • A list of hardcoded terminals, namely mate-terminal gnome-terminal terminator xfce4-terminal urxvt rxvt termit Eterm aterm uxterm xterm roxterm termite lxterminal terminology st qterminal lilyterm tilix terminix konsole kitty guake tilda alacritty hyper

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1