How would one detect which terminal emulator (xterm
, gnome-terminal
…) is used in the current desktop environment ? Like xdg-open
, but for the terminal emulator.
I already tried the xdg-terminal
script on my Xubuntu installation, with no luck :
./xdg-terminal.sh: 305: [: x: unexpected operator
./xdg-terminal.sh: 399: [: xxterm: unexpected operator
xdg-terminal: configured terminal program 'xterm' not found or not executable
It would be for using in a C++ program, so any script, package or built-in command will do.
Thanks for the help !
Best Answer
Short answer
There is no standard for knowing what the default terminal emulators is across distros. In fact, the user might use 'by default' a completely different terminal than the one that ships with the desktop environment. You would only be able to guess it by looking into different system variables and config files.
Longer answer
You can try to guess your way forward with
$TERM
Please refer to
man term.5
and/orman term.7
(pages 5 and 7 of the term manual page).On my Manjaro i3 install
which is the other name for
urxvt
. So you can't even expect to get the right name of the default terminal.As detailed in this reply
Advice : just go through a list of known terminal emulators
By default i3 comes with
i3-sensible-terminal
. According to it's manualAnd the way it works is just by going through the list of commonly used terminal emulators
Where
$TERMINAL
is usually set in the aforementioned startup scripts when it is used.x-terminal-emulator
is the Debian way of asking for the default terminal (works on Ubuntu)In a bash script, that would give something along the lines of