Choose terminal when using qube widget "Run terminal"

Hi,

Recently, the terminal started from my Fedora 41 qubes changed from gnome-terminal to Terminal. I don’t really care about my terminal emulator usually, but the new one has horrible performance on Qubes OS.

Is it possible to configure which terminal is started when using “run terminal” from the qube manager systray?

1 Like

The priority and precedence of Terminal emulators is decided within /usr/bin/qubes-run-terminal executable. Which is a part of qubes-core-agent-linux repository.

Recently there were two changes to it to change the order of lookup for installed Terminal emulators. I was personally responsible for ptyxis having more priority than gnome-terminal. Since it is inline with upstream Fedora and GNOME policies. The 2nd change happened during the most recent update.

You can override the lookup behavior by defining your desired $TERMINAL environment variable in the AppVM or TemplateVM.

Thanks for your reply.

Where do you override this exactly? I tried to do it in my .bashrc , restarted the qube but this did not affect the terminal started.

Same if I inject the variable in /etc/profile.d/terminal.sh

:woman_facepalming: I’m in an appvm

I added this in my template VM, but the terminal started is still not the one I want:

> cat /etc/profile.d/terminal.sh 
if test -f /usr/bin/gnome-terminal
then
    export TERMINAL=/usr/bin/gnome-terminal
fi

When I open a shell, I can see TERMINAL is correctly set.

@ben-grande The above is related to the recent patch to qubes-run-terminal. I can confirm that it does not honor the $TERMINAL environment variable if run via qubes.StartApp service?

I’m not super familiar with how the agent is working, maybe the variable should be defined in a systemd service?

It’s not better trying to do it using systemd, what I did:

bash-5.2# systemctl edit qubes-gui-agent.service
bash-5.2# cat /etc/systemd/system/qubes-gui-agent.service.d/override.conf
[Service]
Environment=TERMINAL=/usr/bin/gnome-terminal
bash-5.2# systemctl restart qubes-gui-agent.service

At least in its Feb 18 incarnation, /usr/bin/qubes-run-terminal has this order hard-coded (regardless of any environment variables):

  1. x-terminal-emulator
  2. ptyxis
  3. gnome-terminal
  4. kgx
  5. then a list of “xfce4-terminal konsole urxvt rxvt termit terminator Eterm aterm roxterm termite lxterminal mate-terminal terminology st xterm”

So… hard-coded.
It is a Bash script, you can read it too. :smile:

Maybe the solution is to change the “alternatives” (in the template) of x-terminal-emulator to point to gnome-terminal?

Yes. But it should be possible to override it with “$TERMINAL” environment variable. And it does not work.

It is possible to hammer and chisel our ways by manually editing that script or removing unwanted Terminal Emulators from the TemplateVM. But there should be the better solution and the “$TERMINAL” should work.

2 Likes

Well… changing the alternatives is elegant and Linux-y too.

1 Like

Thanks! Problem solved through the template.

cat <<EOF > /usr/local/bin/x-terminal-emulator
#!/bin/sh

test -f /usr/bin/gnome-terminal && /usr/bin/gnome-terminal
EOF

chmod +x /usr/local/bin/x-terminal-emulator 
3 Likes

The $TERMINAL solution should be better, but yet I was not able to get it to work.

1 Like

Shouldn’t there have been a forum-wide/user vote on this?

2 Likes

I don’t think so. The voting user base would also not be representative of the whole user base.

Qubes OS has the policy of following upstream as close as possible, this is what @alimirjamali did here.

1 Like

There are few things to avoid in open source world if you want to have a better life:

  1. Discussions and debates on the best Filesystem as the default.
  2. Discussions and debates on the best text editor as the default.
  3. Discussions and debates on the best compression algorithm to be the default.
  4. Discussions and debates on the best desktop environment.

My advise is to run away and do not look back everywhere you see such a debate. I personally do not touch them with a barge pole.

p.s. I forgot to include the debate on the best terminal emulator debate :man_facepalming:

5 Likes

Understood. But if users, as with the OP, are experiencing performance issues with the change perhaps it’s something worth noting.

2 Likes

You forgot #0 : use of Fedora in dom0! :joy:

2 Likes

I believe that this is indeed a good feature to develop. The qube could query dom0 via qubesdb for a feature such as terminal-preference which could have the value of choice1 choice2 choice3 ... and override the default ones.

4 Likes

Can’t reproduce with my changes applied.

The changes were tagged with 4.3…, will be only available on Qubes R4.3, was not backported.

An easy way to check is seeing if my changes are present:

grep -- TERMINAL "$(command -v qubes-run-terminal)"

And if it is there, discover why a terminal is being used:

printf '%s\n' "t=$TERMINAL"
sh -x "$(command -v qubes-run-terminal)"

Note variables of profiles are only considered when a login happen, same on systemd, only when it starts.

The gnome-terminal doesn’t seem to be available on fedora-41:

command -v gnome-terminal; echo $?

Is this a question?

Works for me^TM.

An easy way to check if the variable is being set is by modifying the beginning of the script with this (will work when zenity is available, else, redirect variable to a temp file):

#!/bin/sh
set -eu
text="TERMINAL=${TERMINAL-}"
printf '%s\n' "$text" | tee -- /tmp/log
if command -v zenity >/dev/null; then
  zenity --info --text "$text"
fi
exit
1 Like