On an Ubuntu 17.10 system currently Google Chrome (installed via deb) is my default browser.
I installed brave browser with snap install brave --candidate then launched it from the command line.
As expected brave launches and asks to be made the default.
I say “Use Brave”. I then try clicking a link but this launches in chrome, the previous default, not Brave.
any DENIED messages in syslog ? (my guess would be that the browser-support interface needs some extension to be allowed to set that config value for the desktop session)
Please note that these write accesses for /etc/opt/chrome are pure noise-- the non-root user does not have write access to these directories since /etc is root:root owned. (Ie, if apparmor allowed it, DAC would not).
smells like we might need something similar to xdg-open here and allow that in the browser-support interface… (a forwarder from the core snap into the user session to call xdg-settings there then)
I agree with @ogra. What I think is happening is that xdg-settings is not in the snap so you get the execvp failure, but then if it was in the snap, it would (presumably) end up changing /home/user/snap/brave/revision/.config/… which won’t influence the default browser of the session. I suspect we need something like xdg-open for xdg-settings because we will want to mediate what snaps can change via an out of process helper, and it can modify the session default application set.
@jdstrand We also need to think through the implications of allowing snaps to hook themselves up as default. It doesn’t feel like something that should be done from inside out.
@niemeyer - I agree. I’m not sure what this would look like for applications that already use xdg-settings (thankfully, it appears to typically only be the browsers (though they all seem do it)).
To me, this feels similar to interface connections where the user can issue a snap command to make a browser the default on the system. Not sure how to hook that into xdg-settings, if at all.
Perhaps one way to do it would be snapd has an xdg-settings that is called, but instead of silently granting the request, the user is prompted graphically by snapd’s xdg-settings. This is getting into the area of ‘contextual prompting for interface connections’, so may want to think about xdg-settings in that context as well.
So, snapd already lets an application advertise itself as handling a particular mime type or URL scheme via the MimeType key in its desktop file. The question is whether a confined application should be able to manipulate the default associations. That should be enough for a snapped web browser to show up in the “default apps” panel in the control center.
My gut feeling is that they shouldn’t be able to make such a change unilaterally: it potentially lets the application capture information the user did not intend. If we do want to let a confined application initiate such a change, it should probably be done via a portal that confirms the change with the user first (and could potentially remember a “no” decision for a badly behaved app that tries to set itself default every time it is started).
@jamesh I think what you’ve proposed sounds like a good end goal solution.
However, the current situation is that browsers prompt users to make the browser the default. Browser vendors have this capability today using debs and rpms etc. While this capability is missing from snaps they are reluctant to ship snaps of their browsers.
Perhaps an interim solution is to create a xdg-settings interface that provides the capability to set the default browser, among other things. This could be a manually connected interface, which can be automatically connected via assertions for trusted publishers, and would be a faster route to unblocking browser vendors while preserving the option to implement more fine grained user controls in the future. Thoughts?
I filed a bug against xdg-desktop-portal suggesting this here:
I don’t think it is worth trying to build an interim solution for the time before we get xdg-desktop-portal support working: trying to build a parallel system with user prompting, etc is probably more work.
So, the main things that block the xdg-settings and xdg-mime utilities from working at the moment are:
$HOME inside the sandbox is a different directory to outside, so ~/.config/mimeapps.list is something else.
if xdg-mime was modified to find the real home directory, the AppArmor confinement would need to allow it to read and write the mimeapps.lst file plus the temporary file used to update it.
And as mentioned above, there is no way to e.g. allow changing the default email client without changing everything else.
I like the suggestion from @jdstrand to handle this similar to how we deal with xdg-open. I.e. to have a xdg-settings binary inside the core snap that proxies to the outside and handle the actual requests via snap userd. I created a a first branch with how this could look like: https://github.com/snapcore/snapd/pull/4073