For Firefox

Starting with version 64, Firefox can optionally use XDG Desktop Portals to handle various desktop features, such as opening a file picker, or handling MIME types. — Arch Wiki | Firefox | XDG Desktop Portal integration

  1. Type about:config in Firefox address bar.
  2. Search widget.use-xdg-desktop-portal.file-picker, set it to 1.
    • 0 – Never
    • 1 – Always
    • 2 – Auto (typically depends on whether Firefox is run from within Flatpak or whether the GDK_DEBUG=portals environment is set)
  3. Done.

For VS Code

These two environment variables: GTK_USE_PORTAL=1, GDK_DEBUG=portals.

Method 1:

  1. Set environment variable GTK_USE_PORTIAL=1.
  2. Add it to your Fish shell (or other shells you use) alias: alias code "GTK_USE_PORTAL=1 code"

Method 2:

  1. Press Meta key to open Application Launcher.
  2. Search for Visual Studio Code.
  3. Right click > Edit Application…
  4. In the popup window, choose Application tab.
  5. Fill the “Environment variable” field: GTK_USE_PORTIAL=1.

But it’s not working on my machine. So I actually use method 1.


Reference: