Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Open with..." dialog for terminal apps uses xterm, regardless of default terminal #3483

Open
mxhagen opened this issue Nov 20, 2024 · 5 comments

Comments

@mxhagen
Copy link

mxhagen commented Nov 20, 2024

Distribution

Arch -- kernel: 6.11.4-arch2-1

Package version

6.2.8

Frequency

Always

Bug description

On a file "Right-click > Open with ..." then selecting a terminal application like Neovim seems to fully disregard my default terminal specified in org.cinnamon.desktop.default-applications.terminal exec as set with gsettings, instead always opening the app in xterm as far as i can tell.

With xterm uninstalled, opening a file in Neovim this way just fails silently.

If I just symlink my terminal to /usr/bin/xterm, it works as expected and Neovim opens the file in my terminal just fine.

Steps to reproduce

  1. Uninstall xterm (possibly uninstall other 'default' terminals like gnome-terminal too — i haven't tried much, just xterm alacritty and st, of which only xterm worked)
  2. Open nemo, on a file "Right-click > Open with ..."
  3. Choose any terminal app — I believe this applies to apps whose .desktop file specifies Terminal=true

Expected behavior

For consistency I guess this should just use the terminal set at org.cinnamon.desktop.default-applications.terminal exec.
This gsettings key is required/used to determine the terminal for the "Open in terminal" dialog within folders already, so I expected the same would apply to "Open with ... > some terminal app", which it doesn't seem to.

Additional information

No response

@besworks
Copy link

besworks commented Jan 8, 2025

I ran into this same problem using Guake Terminal. Nemo has a list of known terminals located here :

static const struct {
const char *exec;
const char *exec_arg;
const gboolean escape_command;
} known_terminals[] = {
{ "alacritty", "-e", TRUE },
{ "color-xterm", "-e", TRUE },
{ "dtterm", "-e", TRUE },
{ "foot", "--", FALSE },
{ "gnome-terminal", "--", FALSE },
{ "kgx", "-e", TRUE },
{ "kitty", "--", FALSE },
{ "konsole", "-e", TRUE },
{ "lxterminal", "-e", TRUE },
{ "mate-terminal", "-x", TRUE },
{ "nxterm", "-e", TRUE },
{ "rxvt", "-e", TRUE },
{ "sakura", "-x", TRUE },
{ "st", "-e", TRUE },
{ "terminator", "-x", TRUE },
{ "terminology", "-e", TRUE },
{ "tilix", "-e", TRUE },
{ "wezterm", "--", TRUE },
{ "xfce4-terminal", "-x", FALSE },
{ "xterm", "-e", TRUE },
};

If your terminal is not on that list, then GLib.find_program_in_path is used to pick the first known terminal that it can find on your system.

To work around this, I wrote a script and symlinked it to /usr/local/bin/alacritty which is at the top of the known terminals list and uses the same exec-arg as guake (-e). If you're lucky this could be as simple as :

#!/bin/sh
neovim "$@"

For Guake, I had to get a little more creative...

@mxhagen
Copy link
Author

mxhagen commented Jan 10, 2025

"Nemo has a list of known terminals ..."

Hmmm, that is weird. As stated in my original post, alacritty and st don't work either, but they are in this known_terminals[].

In the code, nemo does seem to be looking up org.cinnamon.desktop.default-applications.terminal exec after all.
(I assumed it just used xterm by default instead and that was why i raised this issue in the first place.)

Even so, setting this gsettings key to alacritty or st (while they are installed of course) still does not work.
If xterm is installed it opens that. If not, nemo just does nothing.

This is especially confusing to me as even in the fallback case using g_find_program_in_path(...), alacritty should be found before xterm but only xterm ever seems to be found.

Symlinking either the other terminals to usr/bin/xterm makes both of them work, though it is a workaround.

@besworks
Copy link

alacritty should be found before xterm but only xterm ever seems to be found.

That's what I would expect too. It probably has to do with the order of the bin directories in your $PATH. Like if PATH=/usr/bin:/usr/local/bin and xterm is in /usr/bin but alacritty is in /usr/local/bin then xterm would be found first and used. I put my symlink in ~/.local/bin/ which is higher up in my path than /usr/bin/xfce4-terminal which is the only other emulator installed on my system.

I don't think it's ideal to be symlinking over another app but it gets the job done for now. However, it seems to me like the behavior of this function should be changed so that the gsettings values are respected if set, but fallback to this list if not.

Even better would be an option in the UI to allow the user to select their preferred terminal. The known terminals list could still be used to automatically populate the exec-arg field, but show a warning and let the user fill in the value if not.

@mxhagen
Copy link
Author

mxhagen commented Jan 10, 2025

It's not a problem with order, since alacritty is just never found. Also they are all in the same directory: /usr/bin.

@besworks
Copy link

It sounds like you're using an older version of nemo. The method for detecting known terminals changed on June 4th 2024. If you are using a version from before then, xterm is the fallback if the few hardcoded checks fail:

if (prefix == NULL) {
gchar *check = NULL;
check = g_find_program_in_path ("gnome-terminal");
if (check != NULL) {
/* Note that gnome-terminal takes -x and
* as -e in gnome-terminal is broken we use that.
20201114 - There looks to be an issue with -x now with gnome-terminal
and -- is now the recommended option */
prefix = g_strdup_printf ("gnome-terminal --");
} else {
check = g_find_program_in_path ("nxterm");
if (check == NULL)
check = g_find_program_in_path ("color-xterm");
if (check == NULL)
check = g_find_program_in_path ("rxvt");
if (check == NULL)
check = g_find_program_in_path ("xterm");
if (check == NULL)
check = g_find_program_in_path ("dtterm");
if (check == NULL) {
check = g_strdup ("xterm");
g_warning ("couldn't find a terminal, falling back to xterm");
}

If you can't update to the latest version, your best bet to workaround this would be to symlink over gnome-terminal or nxterm as those are the first and second ones checked.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants