Set Default Terminal for applications launched from rofi menu

Issue

The default terminal when launching terminal based applications is uxterm. I would like this to be xfce4-terminal. This is not the same issue as “how do I set my default keybinding to open xfce4-terminal”. I have tried to parse multiple arch wiki and other pages on how to set default applications with xdg-open, mimetypes, etc. I am lost!

Setup

My ~/.config/i3/config file is configured so that mod+Enter opens xfce4-terminal.
After default installation the result of echo $TERM was xterm-color
I have since set the TERM variable in my .bashrc file to “xfce4-terminal”
Echo $TERM results in “xfce4-terminal”

Expected / desired behaviour:

mod+d to open my rofi applications launcher and selecting htop, ranger or other terminal based applications should launch these applications in xfce4-terminal

Current behaviour:

mod+d and selecting htop or ranger results in the application being launched in uxterm.

Additional notes

If I can get help with this, I can make sure I set my default applications (sometimes links from TUI apps open in firefox and not brave for example).
Would be good to get a best practice on this, i.e. should these variables/defaults be controlled in the user (home) rectory, or globally?

This post seems to have some help. But I’d prefer to set this up in a standard linux way, rather than the YAD settings, unless this is the only way in EOS?

LINK to my SPECS

EDIT

setting variable TERM=xfce4-terrminal in .bashrc actually messed up my shell - for example ‘clear’ would return “unknown terminal xfce4-terminal”

1 Like

This is expected. This variable is not what you think. Read Archwiki - Environment variables for more.
There is only an unofficial/frequently used var for the default terminal: TERMINAL
But each rc provider for WM/custom keybindings configuration will set terminal differently.
Most of them hardcode terminal app, others use $TERMINAL exporting this var in ~/.profile.
You should look in i3 config to confirm how those keybindings work.

i am not sure if this is even possible to apply as a per default rule to all apps using terminal…

If it can help :

(I use i3 on Arch)

My terminal prefrence is set in ~/.profile :

export TERMINAL=“st”

In my i3 config file, default terminal is set to :

bindsym $mod+Return exec $TERMINAL

and if i need to configure a terminal application in i3 config file, i use :

bindsym $mod+g exec “$TERMINAL -e ranger”

4 Likes

also possible to have *.desktop files modified to do that … as dmenu will use such.

1 Like

Some application for example i3-sensible-terminal go through their own list of terminal and select the ones on top first.

From https://man.archlinux.org/man/i3-sensible-terminal.1:

It tries to start one of the following (in that order):
•$TERMINAL (this is a non-standard variable)
•x-terminal-emulator (only present on Debian and derivatives)
•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

Please don’t complain about the order: If the user has any preference, they will have $TERMINAL set or modified their i3 configuration file.

Possible solutions:

  • Try using the TERMINAL variable instead if TERM.
  • Remove uxterm so that the applications default to only xfce4-terminal.

I am not sure what this refers to, but the .desktop idea is one more of the possible solutions. Using env var $TERMINAL is one and explained very well by @Erreffel1 .
EnOS or any distro, can

  • provide a script default-terminal file in /usr/bin/, with a random/distro preferred terminal (example content: alacritty "$@")
  • provide a default-terminal.desktop file, installing it in /usr/share/applications/, with Exec=default-terminal).
  • Then using those in all provided config-skel files (using appropriately)
  • A simple script/app could change user’s default terminal setting, just symlinking in ~/.local/share/applications/ to whatever preferred terminal is chosen (from a list of installed at the time?).

I have been using this technic for some time with prime-run :stuck_out_tongue: , since my desktop has Intel and a 390/fermi nvidia card. No xorg.conf files exist. Everything runs on Intel and when an app needs more, I use prime-run <appname>. (using DRI-PRIME=1 creates a parsing mess in several cases)

cat /usr/local/bin/prime-run
#!/bin/bash
#__NV_PRIME_RENDER_OFFLOAD=1 __VK_LAYER_NV_optimus=NVIDIA_only __GLX_VENDOR_LIBRARY_NAME=nvidia "$@"
DRI_PRIME=1 "$@"

Edit: I forgot to say, I am using nouveau, of course and right now I test gnome wayland session, which just works.

Disclaimer: I don’t play games. I use my time productivelly :rofl:

1 Like

i3 could need that in configs… but using GNOME p.e. it will use gnome-terminal already without the need to set it…

is working for exactly initial question is about…
for me I need to remove the “Gänsefüßchen” like so:

export TERMINAL=xfce4-terminal

in my ~/.profile

2 Likes

we do only have xfce4-terminal in the configs for the two themed installs xfce4 and i3 and yea we do not change terminal for p.e. GNOME or Plasma or Mate e.t.c they us the default one from default configs we got from arch repo…

2 Likes

Maybe you could create some wrapper for rofi the same way it is possible for dmenu?
Here is an example dmenu_recent. For the first time you run a software you need to specify if it should run in terminal or in background as a standalone application.

Or make use of *.desktop files or run custom scripts from you ~/.local/bin that is just a custom start script for specific softwares.

1 Like

Wow thanks everyone, I’ve been super busy and haven’t had a chance to check the forum. I appreciate all the replies and will update you once I’ve tried them.

$TERMINAL - I had seen some info to this effect
i3-sensible-terminal - also had seen some info to this effect, I’ll review the man page and figure out how to prioritize terminals
Overall I do think it has to do with dmenu / .desktop files, so I’ll investigate that as well.

I think this is “quotation marks” in English, if you mean the " “” ".

will be what you need … very simple…

this worked amazingly!

export TERMINAL=xfce4-terminal

Now htop and other rofidmenu launched terminal based applications launch with the correct xfce4-terminal and on the correct workspace (ws1)

Thanks everyone!

Yep, that worked!

UPDATE

Thanks to everyone that commented!
@petsam and @joekamprad suggested that:

  1. Create a file in the home folder ~/.profile
  2. export TERMINAL=xfce4-terminal

  3. Reboot

New Behaviour

  1. When selecting HTOP or RANGER from the Mod+D (rofidmenu), these terminal based applications open in xcfce4-terminal.
  2. They also open on the assigned workspace for xfce4-terminal (default, ws1)

Potential Changes

  1. Set TERMINAL to another terminal app for a simple way to open HTOP or RANGER on the same workspace (ugly hack), or
  2. configure HTOP and RANGER to open on the same workspace from where you launched it.
  3. I’m likely gonna keep it the same, opens on WS1
# bind program to workspace and focus to them on startup:

assign [class="Xfce4-terminal"] $ws1

assign [class="(?i)firefox"] $ws2

assign [class="Thunar"] $ws3

assign [class="Thunderbird"] $ws4

assign [class="TelegramDesktop"] $ws5

assign can be changed to :wink:

1 Like