#1003206 libglib2.0-0: the terminal for desktop files with Terminal=true should be configurable

Package:
libglib2.0-0
Source:
glib2.0
Description:
GLib library of C routines
Submitter:
Vincent Lefevre
Date:
2025-06-16 11:25:01 UTC
Severity:
normal
Tags:
#1003206#5
Date:
2022-01-06 09:39:17 UTC
From:
To:
Opening an unsupported text/* file with Emacs silently fails.
For instance, on https://homepages.loria.fr/PZimmermann/CORE-MATH/
the link "glibc" for acos / binary32

https://homepages.loria.fr/PZimmermann/CORE-MATH/acosf-v1.patch

is served as text/x-diff (as seen with wget, since this is not clear
with Firefox). Since text/x-diff is not supported, Firefox proposes
to open it with

  Emacs (Terminal) (default)

but nothing happens, not even an error message.

If Firefox is started in a terminal, I can see:

Can't locate utf8.pm:   /usr/share/perl5/utf8.pm: Permission denied at /usr/lib/x86_64-linux-gnu/urxvt/urxvt.pm line 463.
BEGIN failed--compilation aborted at /usr/lib/x86_64-linux-gnu/urxvt/urxvt.pm line 463.
Compilation failed in require at -e line 1.
BEGIN failed--compilation aborted at -e line 1.
urxvt: unable to initialize perl-interpreter, continuing without.

Indeed there is no such file "/usr/share/perl5/utf8.pm". So there
is something wrong with the default Firefox configuration and error
reporting.

#1003206#10
Date:
2022-01-06 11:21:45 UTC
From:
To:
Better bug title, since there are no issues with "Emacs (GUI)".
#1003206#17
Date:
2022-01-06 20:58:36 UTC
From:
To:
Sounds like your terminal has a problem, not Firefox.

Mike

#1003206#22
Date:
2022-01-06 23:43:55 UTC
From:
To:
I don't know why urxvt is failing, but anyway, the main question
is why Firefox wants to start urxvt, and not xterm (the terminal
I normally use).

This is even not what x-terminal-emulator points to:

lrwxrwxrwx 1 root root 15 2015-10-26 13:32:50 /etc/alternatives/x-terminal-emulator -> /usr/bin/uxterm*

#1003206#27
Date:
2022-01-07 00:17:22 UTC
From:
To:
file/Emacs's configuration/whatever wants to use urxvt, because
Firefox won't do that on its own.

Mike

#1003206#32
Date:
2022-01-07 01:04:01 UTC
From:
To:
There's no mention of rxvt in
/usr/share/applications/emacs-term.desktop

Anyway, this is Firefox that starts the application. Unfortunately,
http://kb.mozillazine.org/File_types_and_download_actions and
https://firefox-source-docs.mozilla.org/uriloader/exthandler/index.html
are silent on this subject.

#1003206#37
Date:
2022-01-07 01:18:11 UTC
From:
To:
Firefox starts whatever glib tells it is in the desktop file. If the
command in the desktop file ends up running urxvt, it's not Firefox's
fault. If the desktop file says "Terminal=true" and glib tells Firefox
to run urxvt, it's not Firefox's fault.

Mike

#1003206#42
Date:
2022-01-07 01:20:11 UTC
From:
To:
https://www.reddit.com/r/linuxquestions/comments/jelish/change_the_default_terminal_emulator_for_all/
is about

  Change the default terminal emulator for all .desktop files with
  Terminal=true?

which is the case of the emacs-term.desktop file. There's an answer
saying:

  This really depends on what's interpreting the desktop entry file.
  Programs that use Glib, for instance, are unfortunately still stuck
  with a hard-coded list of terminal applications.

So this would really come from Firefox or a library it uses.
I can see that firefox depends on libglib2.0-0, but is it what
it uses to start applications?

Another answer mentions /etc/alternatives/x-terminal-emulator for
Debian-based systems, but here it is not used (it points to uxterm
as I've said).

#1003206#47
Date:
2022-01-07 01:23:44 UTC
From:
To:
OK, so the bug would be in libglib2.0-0 (which uses a hardcoded
list of terminals as said in the reddit post I've mentioned in
my other message)?

#1003206#52
Date:
2022-01-07 01:25:36 UTC
From:
To:
Apparently yes.
#1003206#57
Date:
2022-01-07 03:11:04 UTC
From:
To:
Control: reassign -1 libglib2.0-0 2.70.2-1
Control: retitle -1 libglib2.0-0: the terminal for desktop files with Terminal=true should be configurable
Control: tags -1 upstream
Control: forwarded -1 https://gitlab.gnome.org/GNOME/glib/-/issues/338
Control: affects firefox

So reassigning.

Concerning the urxvt failure, this is due to the fact that firejail
blacklists Perl for security reasons and urxvt needs Perl modules.
As a workaround, firejail should also blacklist rxvt in this case,
so that glib won't see it and won't try to run it (so it will run
xterm instead). I've submitted a pull request for firejail:

https://github.com/netblue30/firejail/pull/4831

and also reported a bug for Debian:

https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1003259

#1003206#78
Date:
2025-06-15 11:11:55 UTC
From:
To:
Version: 2.75.4-1

Since glib2.0/2.75.0-1, if you have xdg-terminal-exec(1) in the PATH, it
is used as the default terminal emulator as a higher priority than any
other.

One way to get xdg-terminal-exec into the PATH is to install the
xdg-terminal-exec Debian package, which provides a way to configure a
personal and/or desktop-environment-specific choice of terminal
emulator. This has been proposed as a freedesktop.org standard for
choosing the default terminal emulator, and at least ptyxis and
gnome-terminal (possibly others) support making themselves a
user-specific default in this way.

Another way is to have a directory in your $PATH (for example ~/bin or
/usr/local/bin) and put an executable script or symlink there, named
xdg-terminal-exec. To conform to the exepcted API, it should treat all
of its arguments as a command to execute in a terminal. For example, one
of these would be suitable:

     #!/bin/sh
     exec gnome-terminal -- "$@"

     #!/bin/sh
     exec xterm -e "$@"

Since glib2.0/2.75.4-1, this is documented in
<file:///usr/share/doc/libglib2.0-0t64/README.Debian> or
<file:///usr/share/doc/libglib2.0-0t/README.Debian> as appropriate for
the installed package name.

     smcv

#1003206#83
Date:
2025-06-16 11:13:49 UTC
From:
To:
First, the issue with Firefox seems obsolete as

https://bugzilla.mozilla.org/show_bug.cgi?id=196078

was fixed one year ago, i.e. unrecognized text/* files now open
in Firefox instead of Emacs via a terminal. I can no longer find
to a way to make Firefox open a terminal.

BTW, the related firejail issue with urxvt has been fixed too.

If this still matters for Firefox, the issue is that it is not
installed by default.