Support native KDE open/save dialogs in Firefox
Open, HighPublic

Description

Firefox 64 can use native KDE open/save dialogs!!!

To support this, two changes need to be made to the packaging:

  1. Install the xdg-desktop-portal and xdg-desktop-portal-kde packages as dependencies
  2. Set GTK_USE_PORTAL=1 in Firefox's desktop file, by making the Exec= line read Exec=GTK_USE_PORTAL=1 /usr/lib/firefox/firefox --new-window %u.

It can't be set in the global environment or else Thunderbird will crash on launch.

I can confirm that this works for me! I now have native KDE file dialogs in Firefox 64.

ngraham created this task.Dec 15 2018, 5:49 AM
ngraham updated the task description. (Show Details)Dec 15 2018, 5:55 AM
ngraham triaged this task as High priority.Dec 15 2018, 5:58 AM

Marking as high priority since KDE users have wanted this for, like, decades, and I think we would get some good press if we were the first to support it out of the box.

I just tried on manjaro linux.
Effectively FF will use native KDE dialogs, BUT it does not pre-fill the file name where to save.. then it lost the name given by the website.
Is it because I miss a setting or something else?

As like that I prefer the GTK dialog even it's not integrated in my DE, or to use the suse patched FF.

I just tried on manjaro linux.
Effectively FF will use native KDE dialogs, BUT it does not pre-fill the file name where to save.. then it lost the name given by the website.
Is it because I miss a setting or something else?

Already fixed: https://bugs.kde.org/show_bug.cgi?id=402077

clivej added a subscriber: clivej.Dec 16 2018, 2:22 PM

Thanks for this info Nate, FireFox 64 looks a lot better and more useful on Plasma :)

Murz added a subscriber: Murz.Dec 16 2018, 8:49 PM

We cannot modify the firefox desktop file.

Suggestion for how/where to apply the setting otherwise?

Or ~/.profile? But either one will affect all apps, not just Firefox. I can't guarantee that there won't be any regressions in this case. :/

Maybe we could ship a modified .desktop file but install it to ~/.local/share/applications? That way it would take precedence over the system one, but the system one would be untouched. This is what happens if you use KMenuEdit to edit the desktop file yourself, in fact.

Murz added a comment.Dec 28 2018, 5:49 AM

In /etc/profile.d we can create new file firefox-kde-dialogs.sh that will apply GTK_USE_PORTAL=1 for all users.

GB_2 added a comment.Dec 28 2018, 8:12 AM

Or ~/.profile? But either one will affect all apps, not just Firefox. I can't guarantee that there won't be any regressions in this case. :/

Maybe we could ship a modified .desktop file but install it to ~/.local/share/applications? That way it would take precedence over the system one, but the system one would be untouched. This is what happens if you use KMenuEdit to edit the desktop file yourself, in fact.

I think the problem with local desktop files is that if you remove Firefox or it has an updated desktop file the local one is still showing up.
Is there really no way to make a modified system-wide desktop entry?

GB_2 added a comment.Dec 28 2018, 8:17 AM
This comment was removed by GB_2.

I think the problem with local desktop files is that if you remove Firefox or it has an updated desktop file the local one is still showing up.
Is there really no way to make a modified system-wide desktop entry?

Yes, you could try to persuade Ubuntu to package Firefox with this option already there in the .desktop file, if it would have no adverse impact while running other DEs.

Many other options would have problems like those already identified such as: being overwritten by Firefox upgrades, overriding the default .desktop entry which could cause important changes in the default to not be used, being persistent even if a user decides to remove or modify Firefox on their system, may still apply if the user decides to install or log in to another DE on a kubuntu system.

ach added a subscriber: ach.Dec 28 2018, 10:22 AM

What I usually use to tweak my systems:

a) Patch /usr/bin/startkde and put the env var there. Simple and only set for a plasma session

b) Instead of modifying the desktop file, one could create a wrapper script called firefox

 and put it to e.g. /usr/share/firefox-kde/   Then put this dir to PATH during plasma
startup

Does not work on systems with a local firefox wrapper (like my systems ;-) )

c) generate a script that is source'ed during plasma startup ( one of ~/.config/autostart*/ ?) and set the env var or PATH for b) above)

d) can we use the alternative system to make /usr/bin/firefox a link a firefox.kde wrapper script?
(check if we're inside a plasma session, then set env var)

e) dpkg-divert?

ach added a comment.Dec 28 2018, 10:28 AM

Oh, maybe: prevent problems(?) with sh -> dash systems use the env tool:

Exec=env GTK_USE_PORTAL=1 /usr/lib/...

Set it via a script in /etc/xdg/plasma-workspace/env/ ?

Using export GTK_USE_PORTAL=1

rikmills added a comment.EditedDec 28 2018, 10:11 PM

Set it via a script in /etc/xdg/plasma-workspace/env/ ?

Using export GTK_USE_PORTAL=1

As in https://dev.getsol.us/R4535:a6093baf617dbaa7344de4ac1a8d48137f3e8c7f

Ignoring non relevant things in that change!

rikmills added a comment.EditedDec 28 2018, 10:46 PM

In our case adding a 50-firefox.sh (arbitrary name) containing export GTK_USE_PORTAL=1 to /usr/share/kubuntu-default-settings/kf5-settings/plasma-workspace/env/ seems to work.

In our case adding a 50-firefox.sh (arbitrary name) containing export GTK_USE_PORTAL=1 to /usr/share/kubuntu-default-settings/kf5-settings/plasma-workspace/env/ seems to work.

Test build of kubuntu-settings adding this change here:

https://launchpad.net/~kubuntu-ppa/+archive/ubuntu/staging-misc/+sourcepub/9804332/+listing-archive-extra

Please test.

Note: reminder that you need both xdg-desktop-portal and xdg-desktop-portal-kde packages installed, and restart your session.

mparillo added a subscriber: mparillo.EditedDec 29 2018, 2:41 PM

Before: Cross-platform FF Dialogues on Kubuntu Daily Build (DD, fully updated).

$ sudo add-apt-repository ppa:kubuntu-ppa/staging-misc
$ sudo apt update && sudo apt full-upgrade -y && sudo apt autoremove -y

Restarting FF had no effect. Re-booting, and the Save Page As... and Open File... Dialogues did not appear at all. Possibly because:

$ apt-cache policy xdg-desktop-portal
xdg-desktop-portal:
  Installed: (none)
  Candidate: 1.0.3-1
  Version table:
     1.0.3-1 500
        500 http://us.archive.ubuntu.com/ubuntu disco/main amd64 Packages

So I installed it (should have done this first)

$ sudo apt install -y xdg-desktop-portal

Rebooted again.

And the lovely KDE versions of Save Page As... and Open File... Dialogues are there.
Note: I used to call that panel kdialog, though kdialog does not appear on the window title bar.

rikmills added a comment.EditedDec 29 2018, 4:26 PM

So I installed it (should have done this first)

$ sudo apt install -y xdg-desktop-portal

Yeah, should we adopt or keep this change I'll add that to the desktop seed and/or settings package recommends, so that users will have it installed by default. I just hadn't bothered in the test package builds.

Ok. Maybe wider testing in Disco 19.04.

https://launchpad.net/ubuntu/+source/kubuntu-settings/1:19.04ubuntu2

kubuntu-settings (1:19.04ubuntu2) disco; urgency=medium

  • Make plasma session set env var 'GTK_USE_PORTAL=1' to enable Firefox native KDE file-picker dialog. Experimental change for wider testing.
  • Recommend the required xdg-desktop-portal & xdg-desktop-portal-kde.

Setting this even Plasma session wide crashes Thunderbird, which is NOT acceptable.

Changes reverted: https://launchpad.net/ubuntu/+source/kubuntu-settings/1:19.04ubuntu3

Solutions to this welcomed.

Looks like this will be fixed with Thunderbird 68, which supports GTK_USE_PORTAL=1: https://bugzilla.mozilla.org/show_bug.cgi?id=1471420.

i.e. not before July 2019?

I guess. :/

Is there really no sane way for us to set the environment variable only for Firefox?

Murz added a comment.Jan 14 2019, 7:18 AM

I have problem that KDE file save dialog in Firefox don't remember last used folder, so I fill issue: https://bugs.kde.org/show_bug.cgi?id=403199 - does it reproduced in your environment?

ngraham updated the task description. (Show Details)Jan 14 2019, 5:28 PM
Murz added a comment.Jan 29 2019, 7:15 AM

Here https://bugzilla.mozilla.org/show_bug.cgi?id=1514605 is Thunderbird bug report about crash, can we add backtrace report for increase solving the bug?

FWIW this is being considered for Neon in D18726: hijack firefox and force portals upon it.

Maybe we could do something similar?