18

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?

4
  • Is this issue only with Sublime text editor or with all applications? If it is only with Sublime text edtitor, are you using a snap or flatpak version?
    – DK Bose
    Jun 12, 2019 at 2:06
  • It happens with other software as well (see edit), but actually not all I noticed. I don't now what version Sublime Text is. How do I find out? I installed it from the official repository: sublimetext.com/docs/3/linux_repositories.html
    – Fii
    Jun 12, 2019 at 2:18
  • I don't use Sublime text editor but please see askubuntu.com/questions/1100261/…. I wrote that for Kubuntu 18.04. Maybe things improved in 18.10. Currently, I'm on 19.04 (and 18.04) so I can't help with 18.10. gtk-based applications default to using a gtk-based file chooser. But they can be made to use the qt-based file chooser as described in the link.
    – DK Bose
    Jun 12, 2019 at 2:26
  • My main concern with this GTK file picker is the missing option to use the keyboard to enter paths with autocompletion. But fortunately there is a keyboard shortcut to open the location input field: Ctrl-l (lower case "L").
    – vboerchers
    Apr 4, 2020 at 14:46

3 Answers 3

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
6
  • 5
    That doesn't seem to work for me. Neither starting the application with GTK_USE_PORTAL=1 nor modifying .profile has any effect.
    – Fii
    Jun 12, 2019 at 22:18
  • 1
    Finally, awesome! Worked for me. :) Oh, this environment variable really should be the default under kubuntu..
    – Klaus
    May 27, 2020 at 9:47
  • 1
    This also not workingo for me. I have these two packages installed. Even have GTK_USE_PORTAL=1 in .pam_environment file and nothing, not working.
    – QkiZ
    Jan 4, 2021 at 11:10
  • It worked for me for Thunderbird when invoking explicitly with that variable from terminal. However, exporting it in ~/.profile and relogin to kde did not worked. Thunderbird was using gtk dialog when saving email attachment. Probably, there is another place where environment variables for kde should be defined. I am using Arch by the way.
    – Ashark
    Mar 12, 2021 at 10:26
  • This does not work for me either. I am using pop os and installed dolphin and made it default. Don't know how I am gonna replace this gtk file chooser.
    – lone wolf
    May 16, 2021 at 14:46
4

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).

3
  • The above temporary/permanent solution 1/2 works. There is an error that pops up when you Open folder in something like VSCode or Sublime or Firefox, that says "File or Folder Does not Exist". When you close the error the KDE dialog pops up but unfortunately will not allow you to choose a Folder. (sometimes you can choose a file). Something wonky is happening.
    – user603749
    Dec 10, 2022 at 0:06
  • @user603749 what distro and display server are you using? And what's your plasma and xdg versions? It works for me in all apps you mention (Firefox, VSCode and Sublime). I am on Arch/Garuda, with Wayland; xdg-desktop-portal version 1.15.0, xdg-desktop-portal-kde and plasma itself are version 5.26.4.
    – Peter
    Dec 11, 2022 at 11:38
  • I don't think its Wayland, running on Virtualbox Display: x11 server: MX Linux Operating System: Debian GNU/Linux 11 KDE Plasma Version: 5.20.5 KDE Frameworks Version: 5.78.0 Qt Version: 5.15.2 Kernel Version: 5.10.0-19-amd64 OS Type: 64-bit Processors: 2 × Intel® Core™ i7-3615QM CPU @ 2.30GHz Memory: 3.8 GiB of RAM Graphics Processor: llvmpipe Package: xdg-desktop-portal Version: 1.8.1-1 State: installed Package: xdg-desktop-portal-kde Version: 5.20.5-1 State: installed
    – user603749
    Dec 12, 2022 at 16:55
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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .