Bug 418841

Summary: Cannot set Firefox as a default browser
Product: [Applications] systemsettings Reporter: Matej Mrenica <matejm98mthw>
Component: kcm_componentchooserAssignee: Plasma Bugs List <plasma-bugs>
Status: RESOLVED FIXED    
Severity: normal CC: bugseforuns, gstengel, kde, matejm98mthw, meven.car, meven29, nate, plasma-bugs, sitter, vishalrao
Priority: VHI    
Version: 5.18.3   
Target Milestone: ---   
Platform: Arch Linux   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description Matej Mrenica 2020-03-14 09:55:42 UTC
SUMMARY
Even though FF and FF Nightly are installed, only Chromium and Falkon are listed in System Settings->Applications->Default Applications->Web browser.
Secondly, setting "with the following command" to Firefox doesn't do anything - this setting is ignored and the browser used before is still used.

SOFTWARE/OS VERSIONS
KDE Frameworks Version: 5.67
Qt Version: 5.14.1

ADDITIONAL INFORMATION
Very likely belongs somewhere else, is a distro-level bug or a Firefox bug.
Comment 1 Patrick Silva 2020-03-14 13:19:43 UTC
Same problem on Neon unstable edition. I have Opera, Opera beta and Firefox installed,
I set Firefox as default browser in System Settings->Applications->Default Applications
and Firefox icon appears in favorites list of kickoff after relogin. But each time I restart Plasma session,
the "web browser" dropdown in System Settings->Applications->Default Applications shows a different browser as default despite Firefox icon is always present in favorites list of kickoff. When such dropdown shows Opera or Opera beta as default, Firefox asks if I want make it as default at startup.

Operating System: KDE neon Unstable Edition
KDE Plasma Version: 5.18.80
KDE Frameworks Version: 5.69.0
Qt Version: 5.14.1
Comment 2 Patrick Silva 2020-03-14 14:13:19 UTC
Humm, but I can't confirm on Arch Linux.
Maybe some problem occurs after we use more than one version of Firefox on the same system.
I have never used two versions of Firefox on Arch, but I already used Firefox stable and Firefox nightly (extracted from tar.bz2 file) a few weeks ago on Neon unstable.

Operating System: Arch Linux 
KDE Plasma Version: 5.18.3
KDE Frameworks Version: 5.67.0
Qt Version: 5.14.1
Comment 3 Matej Mrenica 2020-03-14 17:06:24 UTC
It looks like this issue is caused by editing commands to run these (FF) applications. For example I add "GTK_USE_PORTAL=1" to my firefox launcher and after removing it, Firefox reappears in the default application dropdown menu.
Comment 4 David Edmundson 2020-03-14 17:26:51 UTC
Please expand on what was edited.
Comment 5 Patrick Silva 2020-03-14 17:28:34 UTC
I do not use "GTK_USE_PORTAL=1" on Neon unstable and setting Firefox as default fails as explained in comment 1 anyway. :(
Comment 6 Matej Mrenica 2020-03-14 17:40:33 UTC
Detailed instructions:
1. go to app launcher
2. open context menu on firefox
3. select edit application
4. change "command:" 
5. go to system settings -> ...
Firefox should disappear from the dropdown menu
6. reset firefox launcher/link to default for example by deleting ~/.local/share/applications/firefox.desktop
7. relaunch system settings and go to the default browser selector
Firefox should reappear in the dropdown menu.
Comment 7 Matej Mrenica 2020-04-14 07:53:19 UTC
I have noticed something else, applications with edited launchers are not visible in Gnome session. This might help to find a solution.
Comment 8 Méven Car 2020-04-15 08:07:03 UTC
> Even though FF and FF Nightly are installed, only Chromium and Falkon are listed in System Settings->Applications->Default Applications->Web browser.

I don't know about arch, no other distro I know package FF nightly.
Do they have desktop files in desktop path such as "/usr/share/applications/firefox.desktop" that contain in MimeType field "x-scheme-handler/http;x-scheme-handler/https"
If so you may need to logout/login for the app to be seen by kbuildsyscoca.

> Secondly, setting "with the following command" to Firefox doesn't do anything - this setting is ignored and the browser used before is still used.

This seems like an issue.

> Same problem on Neon unstable edition. I have Opera, Opera beta and Firefox installed,
I set Firefox as default browser in System Settings->Applications->Default Applications
and Firefox icon appears in favorites list of kickoff after relogin. But each time I restart Plasma session,
the "web browser" dropdown in System Settings->Applications->Default Applications shows a different browser as default despite Firefox icon is always present in favorites list of kickoff. When such dropdown shows Opera or Opera beta as default, Firefox asks if I want make it as default at startup.

What's in ~/.config/mimeapps.list ?

> Detailed instructions:
> 1. go to app launcher
> 2. open context menu on firefox
> 3. select edit application
> 4. change "command:" 
> 5. go to system settings -> ...
> Firefox should disappear from the dropdown menu

It should not, this is expected behavior.
For the system the desktop file name counts, commands (Exec field of desktop files) do not matter when resolving names / looking for apps.
FYI https://specifications.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html

A better way to achieve what you want, would be to copy the firefox app to a new firefox desktop file for instance in 
"~/.local/share/applications/firefox-local.desktop" and edit this one.
And run kbuildsyscoca/kbuildsyscoca5 or relog to the session. Your new firefox local will be distinct (use another text in field Name).

> I have noticed something else, applications with edited launchers are not visible in Gnome session. This might help to find a solution.

Gnome has certainly another way to setup custom local applications.
They must be using $XDG_DATA_DIRS/applications to look for apps, when in plasma we add ~/.local/share/applications to those paths for local editions.

Please keep your bug about one issue, it is getting confusing.
Comment 9 Nate Graham 2020-04-15 17:29:28 UTC
*** Bug 418311 has been marked as a duplicate of this bug. ***
Comment 10 Harald Sitter 2020-04-16 09:13:19 UTC
I think it would be good if everyone actually established if they are behind portals. For the record firefox is portaled on neon by default.

If this bug is only appearing with portals, which I expect is the case from the comments, then it is a firefox bug and should be reported on the firefox bugzilla really.

> nsGNOMEShellService::IsDefaultBrowser

calls 

> nsGIOService::GetAppForURIScheme

which returns a flatpakHandlerApp due to hitting the portal detection

>   if (ShouldUseFlatpakPortalImpl()) {
>     nsFlatpakHandlerApp* mozApp = new nsFlatpakHandlerApp();
>     NS_ADDREF(*aApp = mozApp);
>     return NS_OK;
>   }

nsGIOService::GetAppForURIScheme will then attempt to cast this to a nsCOMPtr<nsIGIOMimeApp>, which it is not since it is a nsFlatpakHandlerApp

>       gioApp = do_QueryInterface(handlerApp);
>       if (!gioApp) return NS_OK;

as a result IsDefaultBrowser just always returns right there.
Comment 11 Nate Graham 2020-04-17 17:06:11 UTC
*** Bug 420175 has been marked as a duplicate of this bug. ***
Comment 12 Patrick Silva 2020-05-15 17:21:55 UTC
(In reply to Matej Mrenica from comment #3)
> It looks like this issue is caused by editing commands to run these (FF)
> applications. For example I add "GTK_USE_PORTAL=1" to my firefox launcher
> and after removing it, Firefox reappears in the default application dropdown
> menu.
https://bugzilla.mozilla.org/show_bug.cgi?id=1516290

(In reply to Méven Car from comment #8)
> What's in ~/.config/mimeapps.list ?
The problem is no longer reproducible on my neon unstable.
Comment 13 Matej Mrenica 2020-05-15 18:24:20 UTC
Looks like this doesn't happen anymore. Going through the steps in https://bugs.kde.org/show_bug.cgi?id=418841#c6 now the Firefox entry doesn't disappear only looses the icon.