9

I can run Browser from dash with added parameters (like google-chrome --single-process --purge-memory-button) without problem, by editing of .desktop file, but how I could reach the same by running of default browser via triggering open URL event? There is no options applied in this case.

For example if I have document in LibreOffice with URL, after click on it, new instance of browser appear, but no parameters are applied to. How I can change those?

Seth
  • 58,122
Jan
  • 93
  • Create a custom launcher .desktop of Google Chrome in the same folder as the existing one, but with a different name value. Then set it as default in 'Details' > 'Default Applications' – Wilf Dec 19 '13 at 19:03

2 Answers2

4

Editing the .desktop file is enough in this case also because the default applications are called through the .desktop file.

See the /etc/gnome/defaults.list file and the ~/.local/share/applications/mimeapps.list file, the first one contains the system defaults and the second one contains the defaults which you chose instead of the system default.

So basically just look into those files and see which .desktop file is called for which mime type and edit that .desktop file the way you like. The .desktop files can be found in the /usr/share/applications/ directory or if you have overriden a default .desktop that can be found in the ~/.local/share/applications/ directory. (That means if you have a .desktop file with the same name in both directories, the system will always use the .desktop file present in the ~/.local/share/applications/ directory)

E.g. if I want firefox to open links what I click in a terminal in new window instead of in a new tab, I would just make sure that firefox is my default application for browsing, and then just

cp /usr/share/applications/firefox.desktop ~/.local/share/applications/firefox.desktop

to override the default .desktop file, and change the ~/.local/share/applications/firefox.desktop file at the line

Exec=firefox %u

to

Exec=firefox -new-window %u
falconer
  • 15,026
  • 3
  • 48
  • 68
  • Looks fine for firefox, but seems, that chrome is doing something nasty with...

    icewind@icewind-Aspire-4820TG:~$ cat ~/.local/share/applications/mimeapps.list | grep google text/html=google-chrome.desktop x-scheme-handler/mailto=google-chrome.desktop x-scheme-handler/http=google-chrome.desktop x-scheme-handler/https=google-chrome.desktop x-scheme-handler/unknown=google-chrome.desktop

    but $ ls -al /usr/share/applications | grep chrome $ $ ls -la ~/.local/share/applications | grep chrome $ any idea?

    – Jan Dec 20 '13 at 12:04
  • @Jan I don't understand your problem. From your output I see that you have set chrome as the default browser (mimeapps.list), but you don't have a google-chrome.desktop file in your home directory. That is fine, if you have no .desktop file there, then the default system-wide .desktop file is used from /usr/share/applications. If you want to override that just copy it to your ~/.local/share/applications/ directory and it will override the default. – falconer Dec 20 '13 at 16:57
0

In this case you will have to edit the file that handles the execution of the browser. This way you will be sure that the parameters you want will be included when called from everywhere.

This is what I mean:

  1. Move the original file to a different name
  2. With the old name of the original file, create a new script calling the original file with the needed parameters.

I will show an example of how to do this, using chromium-browser.

You will have to be careful when executing the below commands, as super user privileges will be granted, thus you have full rights for your whole system, and, e.g. you can delete or alter everything

  • Backup the old file:

    cp /usr/bin/chromium-browser ~/Documents/backup/

Where /usr/bin/chromium-browser is the executable of your browser and ~/Documents/backup/ is an example backup location. In order to find the location of the executable called each time your browser is launched, you can find it from its desktop file, usually in /usr/share/applications.

This will copy /usr/bin/chromium-browser to ~/Documents/backup/

  • Move the file to a new name:

    sudo mv /usr/bin/chromium-browser /usr/bin/chromium-original

This will rename the executable from chromium-browser to chromium-original

  • Replace the old file's name with a file that passes the parameters you want to the original executable.

For example, in this occasion, create anywhere a file called chromium-browser with the contents:

#!/bin/bash

/usr/bin/chromium-original --param1 --param2 --param3 "$@"

Where --param1 --param2 --param3 are the parameters you want to be executed each time.

The "$@" means "all the parameters passed to this file", which in this case it is usually a URL.

  • Make the file executable and move it to the old file's location

After you save the above file, make it executable. Two ways of doing it, either right click->Properties->Permissions->Allow executing file as program or via terminal: chmod +ax chromium-browser

Finally, move it to the old location of the original executable:

mv ~/chromium-browser /usr/bin/

where ~/chromium-browser the location of the script that you created.

Please note that you do not need to do all these if you want to replace one command of the terminal with the same but with other arguments. You can do this into ~/.bash_aliases using an alias. See How to create a permanent "alias"? for more information.

hytromo
  • 4,904