7

I basically have the same question that was answered over here:

How do I change the browser that gnome terminal opens links with?

Except I am running on Ubuntu 14.04 and am interested in customizing the command line arguments passed to the browser. Is there a way to do this?

Setjmp
  • 263
  • I would assume that you could launch the browser with your own script which includes your customizations and fool the system into using your script to launch your browser. Sorry, I've never done this exactly. If you are using firefox you may find this helpful: https://developer.mozilla.org/en-US/docs/Mozilla/Command_Line_Options – Elder Geek Apr 16 '15 at 19:27

1 Answers1

7

Programs use a variety of other programs to determine the default browser - sensible-browser & xdg-open being two of them.

For xdg-open, you can use it simply by by running xdg-open http://URL, so xdg-open https://www.google.co.uk will open Google for instance.
This should be the same as running echo https://www.google.co.uk in terminal and clicking on the link should open the default browser (in my case, Firefox).
You can see what is the default browser using xdg-settings get default-web-browser:

$ xdg-settings get default-web-browser
firefox.desktop

To set values, you do xdg-settings set default-web-browser LAUNCHER-FILE.desktop:

$ xdg-settings set default-web-browser chromium-browser.desktop

So now running echo https://www.google.co.uk and clicking on the link or running xdg-open https://www.google.co.uk should open Google in the new default browser (in my case now Chromium).

Notice that it links to the program's .desktop file not it's command - this needs to be a valid file in /usr/share/applications (or ~/.local/share/applications). You can easily create your own with a custom command easily by copying a existing one and changing the 'Name' and 'Exec' lines:

$ cp /usr/share/applications/firefox.desktop ~/.local/share/applications/firefox-new-window.desktop
$ gedit ~/.local/share/applications/firefox-new-window.desktop & disown

##Then change Name and Exec lines to `Name=Firefox (New Window)` & `Exec=firefox --new-window %u` respectively
$ update-desktop-database ~/.local/share/applications/
$ xdg-settings set default-web-browser firefox-new-window.desktop

In the above I created a new launcher, edited it so it would launch a new window of Firefox, and updated the database of launcher files and set it to default. Now running xdg-open https://www.google.co.uk opens a new window of Firefox.

More info:

Wilf
  • 30,194
  • 17
  • 108
  • 164