Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Firefox and Chromium "set as default" not including wrapper #4370

Closed
VShell opened this issue Oct 2, 2014 · 16 comments · Fixed by #23516
Closed

Firefox and Chromium "set as default" not including wrapper #4370

VShell opened this issue Oct 2, 2014 · 16 comments · Fixed by #23516

Comments

@VShell
Copy link
Contributor

VShell commented Oct 2, 2014

When "set as default browser" is clicked from within Firefox, it places a custom .desktop file in ~/.local/share/applications, and points to this from mimeapps.list in the same directory. This file launches Firefox without the wrapper when it's opened using xdg-open. The result is that if xdg-open is used when no Firefox window exists, it will be opened without environment variables set correctly, and without plugins.

@domenkozar
Copy link
Member

This is a great example why wrappers are error prone.

@jgeerds
Copy link
Member

jgeerds commented Nov 3, 2014

Is there a easy way to fix this? I don't see one

@edolstra
Copy link
Member

edolstra commented Nov 3, 2014

The easy way is to use a non-absolute path in the .desktop file, i.e. Exec=firefox. This also ensures that after an upgrade, the new Firefox will be invoked.

@VShell
Copy link
Contributor Author

VShell commented Nov 3, 2014

@edolstra This .desktop file is generated by Firefox when "set as default browser" is clicked - it's not one of nixpkgs's .desktop files. That'd involve a patch (which would have to be kept up to date with each Firefox release).

@edolstra
Copy link
Member

edolstra commented Nov 3, 2014

Right, shouldn't be hard to do.

@edolstra
Copy link
Member

edolstra commented Nov 3, 2014

Testing a patch now...

@domenkozar domenkozar added this to the 14.11 milestone Nov 4, 2014
@vcunat
Copy link
Member

vcunat commented Nov 12, 2014

@edolstra: I can't see the patch anywhere -- did it work?

@domenkozar
Copy link
Member

Chromium .desktop file includes Exec=chromium and suffers from the same problem.

@vcunat vcunat changed the title Firefox "set as default" not including wrapper Firefox and Chromium "set as default" not including wrapper Nov 21, 2014
@domenkozar
Copy link
Member

This is handled and detected with mimetypes.

xdg-mime default google-chrome.desktop text/html
xdg-mime default google-chrome.desktop x-scheme-handler/http
xdg-mime default google-chrome.desktop x-scheme-handler/https
xdg-mime default google-chrome.desktop x-scheme-handler/about

@domenkozar
Copy link
Member

Would be really nice to fix this one, any takers?

@7c6f434c
Copy link
Member

I think I have solved it for Firefox; as for Chromium — apparently it is non-trivial to test for me (StumpWM, not a DE)

@domenkozar domenkozar removed this from the 14.12 milestone Apr 19, 2015
benley added a commit to benley/nixpkgs that referenced this issue Aug 4, 2015
It helps to actually pass the URL to chromium :)

Related to NixOS#4370
@benley
Copy link
Member

benley commented Dec 28, 2015

There's still no obvious way to set the default browser that I can find - anyone know what the status is here?

@VShell
Copy link
Contributor Author

VShell commented Jan 1, 2016

A possibly reasonable option in the case of Firefox would be to disable the default browser check using the mozilla.cfg preferences file, and write a custom dialog for selecting the default browser in the wrapper itself, a very rough basis being:

if check_is_not_default_browser && [ ! -e ~/.config/nix-wrappers/firefox/never-ask ]; then
  yad --title="Default browser" --text="Would you like to set Firefox as your default browser?" --button="gtk-ok:0" --button="gtk-cancel:1" --button="Never:2" --center
  if [ $? -eq 0 ]; then
    xdg-mime default firefox.desktop text/html
    xdg-mime default firefox.desktop x-scheme-handler/http
    xdg-mime default firefox.desktop x-scheme-handler/https
    xdg-mime default firefox.desktop x-scheme-handler/about
  elif [ $? -eq 2 ]; then
    echo 1 > ~/.config/nix-wrappers/firefox/never-ask
  fi
fi

According to a google, similar should work for Chrome/Chromium, except passing --no-first-run --no-default-browser-check instead of messing with config files.

Opinions?

@layus
Copy link
Member

layus commented Mar 1, 2017

Is there no way to trick firefox into thinking its executable name is the wrapper ?

vcunat added a commit to vcunat/nixpkgs that referenced this issue Mar 3, 2017
Fixes NixOS#4370, hopefully.  It's not clear if it can break anything.
@vcunat
Copy link
Member

vcunat commented Mar 3, 2017

Yes: 0834dbc but this needs some testing, and it affects many browsers.

@layus
Copy link
Member

layus commented Mar 4, 2017

@vcunat I fixed the wrapper to work with 0834dbc (vcunat#2), but we get another issue.

When we update firefox, we end up with a different /nix path, which firefox considers as a different browser. If you restart firefox (for example when installing addons) then you get the not-your-default-browser" warning.

Investaigating MOZ_APP_LAUNCHER as solution, but I start to think that #4370 (comment) may be the most general solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants