19

I'm using Kubuntu 18.10 and have the default file manager, Dolphin, set up quite nicely with servers, favorites etc. in the sidebar.

Now, whenever I want to open a file or folder from within a program, this file picker opens:

Now, many programs open this file/folder picker instead of the Dolphin file picker:

File Picker

EDIT: This happens for example in Sublime Text and Firefox. Preinstalled programs (e. g. Spectacle or Kate) seem to actually do display a Dolphin file picker!

Is there any way to replace this with the Dolphin file picker, or at least get my favorites etc. into whatever this program is?

Fii
  • 291

3 Answers3

11

You want applications to use the KDE file selection dialog so that you can have the appearance matching that of Dolphin.

As you have seen, native applications such as Spectacle do conform, but others don't. This is probably because the non-conforming applications are gtk-based and use the GTK file selection dialog:  

Firefox uses the gtk file selection dialog by default

Firefox using the gtk file selection dialog

To get Firefox, which is a gtk application, to use the KDE file selection dialog, start it from a terminal like this:

GTK_USE_PORTAL=1 firefox

Now, you'll see  

Firefox using the KDE file selection dialog

 

Similarly, you can make gedit, and other gtk applications, use the KDE file selection dialog.  

Here's what you'll see with GTK_USE_PORTAL=1 gedit:  

gedit using the KDE file selection dialog


If you're sure you want to consistently use the KDE file selection dialog, you can add export GTK_USE_PORTAL=1 to the end of ~/.profile. After you log out and log back in, all applications will use the KDE file selection dialog.

Note that the following two packages should be present in your system:

  • xdg-desktop-portal-kde
  • xdg-desktop-portal
DK Bose
  • 44,553
5

The problem

Most GTK - based apps (like Firefox) will open the GTK file picker ("Nautilus") by default, independent of the current desktop environment.

The (temporary) solution

However most GTK apps support using xdg desktop portals. As a prerequisite make sure you have the packages xdg-desktop-portal and xdg-desktop-portal-kde installed and up-to-date. To check if a GTK application supports desktop portals, launch it from the console with environment variable GTK_USE_PORTAL=1 set. For example, to launch Firefox and test the file picker run GTK_USE_PORTAL=1 firefox from your command line. If an application still uses Nautilus even when launched like this, it uses a GTK version which doesn't support the environment variable or the desktop portals. In this case you can't do anything but hope that the program is open-source and you can fix it yourself. There is another alternative, but it is very hacky and I wouldn't recommend it

Permanent solution

To make all apps launch with the environment variable set, create a KDE session environment variable (see KDE UserBase wiki for reference):

  1. Make sure you have installed xdg-desktop-portal and xdg-desktop-portal-kde
  2. Make sure the path $HOME/.config/plasma-workspace/env exists
$ mkdir -p $HOME/.config/plasma-workspace/env
  1. Create a new .sh file in the directory, with any name and the content export GTK_USE_PORTAL=1 KDE will execute any .sh script found in that directory on startup and maintain the environment variables set in them.
$ echo "export GTK_USE_PORTAL=1" >> $HOME/.config/plasma-workspace/env/gtk_use_portal.sh
  1. Reboot/Logout and login again

Note that this will only work as long as you use a KDE session. If you are switching to a Gnome session, the environment variable will obviously not get set by KDE and all applications will revert to their default.

Why not .profile?

Most solutions I found online recommend to set the permanent environment variable in the .profile file. While this works for Flatpak apps, it doesn't seem to work for native apps (as of today). Setting it as a KDE session environment variable works also for most native apps (if they support it).

Peter
  • 51
0

Installation helped me (from pacman-manager) xdg-desktop-portal-gtk from this post https://bugzilla.mozilla.org/show_bug.cgi?id=1639575#c17 enter image description here