How to change default browser AND the command line parameters used to open a link from gnome-terminal

by SetJmp   Last Updated April 16, 2015 21:00 PM

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?

Answers 1

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 will open Google for instance.
This should be the same as running echo 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

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 and clicking on the link or running xdg-open 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 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 firefox, update the database of launcher files and set it to default. Now running xdg-open opens a new window of Firefox.

More info:

April 16, 2015 22:03 PM

Related Questions

How disable blinking cursor in gnome-shell's terminal?

Updated February 15, 2018 18:02 PM

How to make text not wrap in gnome-terminal?

Updated August 02, 2016 08:02 AM