Replace GTK+ file dialog with alternative
Since around 2016 the answer is yes! At least for using the KDE file chooser with GTK3 apps.
Gtk+ developers call this “native file choosers” for “sandboxed applications”, while the primary target for this was Flatpak it also made it possible to use these on Windows. However you can also use this for non-sandboxed/flatpak applications using a trick:
- Install the
xdg-desktop-portal-kde
package: Arch Linux, Debian, Fedora, KDE Neon, Ubuntu (Direct Install link) - If you are not actually using KDE, edit
/usr/share/xdg-desktop-portal/portals/kde.portal
and add the value of$XDG_CURRENT_DESKTOP
, separated by a semi-colon to theUseIn=KDE
line (i.e.:UseIn=KDE;XFCE
) - Add the line
GTK_USE_PORTAL=1
to~/.pam_environment
so that GTK will always behave as if it were in an sandboxed environment - Log out and back in to apply these changes
Related videos on Youtube
Comments
-
gandalf3 almost 2 years
Is there any way to configure GTK+ programs to use a different file dialog?
Reading ancient articles on the default dialog and seeing no difference to the current version does no bode well for it's improvement in the near future.
I've read this question, but I appear to be one of the few to do so in nearly a year. As I mentioned in a comment on that question:
For archlinux there is a patched version of FF for KDE. It works well if you are in KDE and like the stripped down version of dolphin/whatever it is, but unfortunately doesn't seem to change the file selector if you are not using KDE
As I'm currently in a custom openbox setup, Firefox is back to using the disliked GTK+ dialog. But this solution only works for Firefox, so I'd prefer a way to purge this from my system globally.
-
ntninja about 5 yearsI should maybe add that this will not work for apps using the classic
GtkFileChooserDialog
orGtkFileChooserWidget
APIs: These expose the underlying GtkWidgets to the application which would not be available when rendering the file chooser using anything other than GTK. Hence, onlyGtkFileChooserNative
andGtkFileChooserButton
will work and if you see a GTK app still using the GTK file chooser after performing the above steps, you may want to send them a patch. ;-) -
Wyatt Ward about 4 yearsSome "environments" don't use
$XDG_CURRENT_DESKTOP
. I run FVWM as my "X session manager". So I'd be setting it to an empty string, which doesn't sound right. I'm assuming I should just put something to set that value in my login scripts to e.g.fvwm
and then match it inkde.portal
. Also I'd really rather not install flatpak stuff if I can avoid it (xdg-desktop-portal-kde
pulls in flatpak as a dependency in debian). Additionally, I don't think~/.pam_environment
does anything on my install. -
ntninja about 4 years@Wyatt8740: If there is no standard value for
$XDG_CURRENT_DESKTOP
for your configuration making one up and using that is a reasonable solution. If~/.pam_environment
doesn't work try addingsession required pam_env.so user_readenv=1
to end of/etc/pam.d/common-password
(making it the very last session-type plugin executed) or, for X11, try exporting the value in~/.Xsession
instead. At least on my Debian unstable system I see no dependency ofxdg-desktop-portal-kde
onflatpak
, only onbubblewrap
… -
Wyatt Ward about 4 yearsit's through multiple levels of dependency, IIRC. I've figured it out now I think. It might have been related to a metapackage that could be provided by multiple solutions (one of which required systemd). I'm forgetting now. Thanks for the advice at any rate.
-
James Bond over 3 yearsKubuntu 20.04, this method doesn't work.
-
QkiZ over 3 yearsUbuntu 20.10, doesn't work
-
mirabilos about 3 yearsDebian unstable (May 2021), evilwm (thus no DE); this works, I don’t have to set XDG_CURRENT_DESKTOP or edit the file at all @WyattWard
-
Wyatt Ward almost 3 years@mirabilos I might give it a shot again since I'm also on Sid (running FVWM3). Assuming I can avoid the systemd dependency, that is. (edit:
--no-install-recommends
helped; I think this is going to work without getting rid of my sysvinit). Thanks. -
mirabilos almost 3 years@WyattWard mirbsd.org/~tg/Debs/dists/sid/wtf/Pkgs/mirabilos-support/… may also help with that ☺
-
cipricus over 2 years@JamesBond - this is not meant for Kubuntu, but for environments that lack Plasma. See this instead.