9

When I click on a URL (e.g. a URL in output console in bash), it opens using Chrome. Since I have multiple Persons (or users) on Chrome, it seemed to always open using the person with most recently seen window.

Is it possible to make a particular person the default to open URLs like this?

1 Answer 1

5

Ubuntu Unity Desktop uses *.desktop files set the default programs for file types. In order to achieve what you desire you can create a custom *.desktop file for google-chrome just for your user.

This will take a couple of steps:


1. Verify Default Program

Verify that google-chrome.desktop is your default program for opening links:

In Terminal enter: cat ~/.local/share/applications/mimeapps.list.

Output should be something like this:

[Default Applications] text/html=google-chrome.desktop x-scheme-handler/http=google-chrome.desktop x-scheme-handler/https=google-chrome.desktop x-scheme-handler/about=google-chrome.desktop x-scheme-handler/unknown=google-chrome.desktop x-scheme-handler/mailto=google-chrome.desktop text/x-c++src=gedit.desktop

[Added Associations] text/x-c++src=gedit.desktop;

If like in the example google-chrome.desktop is handling the web links then proceed as described. If not you need to set the default program first.


2. Create Custom *.desktop File

Creating a custom google-chrome.desktop file at ~/.local/share/applications/ based on the original /usr/share/applications/google-chrome.desktop file.

In Terminal enter:

cp /usr/share/applications/google-chrome.desktop ~/.local/share/applications/

  • Doing this you will only change the settings for your user and not all users in the machine.

  • If a *.desktop file name from /usr/share/applications/ is duplicated at ~/.local/share/applications/ then the local one takes priority.


3. Edit new *.desktop file

This file will contain many lines for names of options in different languages. We will need to edit all lines starting with Exec=.

Example from my computer at: /usr/share/applications/google-chrome.desktop

Exec=/usr/bin/google-chrome-stable %U

Exec=/usr/bin/google-chrome-stable

Exec=/usr/bin/google-chrome-stable --incognito

In the new file at ~/.local/share/applications/ change these lines by adding the option --profile-directory=Default.

Exec=/usr/bin/google-chrome-stable --profile-directory=Default %U

Exec=/usr/bin/google-chrome-stable --profile-directory=Default

Exec=/usr/bin/google-chrome-stable --profile-directory=Default --incognito

This will make it so every time you open a link it will be opened by the Default user.


Different User

The option --profile-directory= can be set to the name of anyone folder at ~/.config/google-chrome/ that holds user configuration. Examples:

  • Default
  • Profile 1
  • Profile 2
  • etc...

Example:

Exec=/usr/bin/google-chrome-stable --profile-directory=Profile\ 1 %U

Exec=/usr/bin/google-chrome-stable --profile-directory=Profile\ 1

Exec=/usr/bin/google-chrome-stable --profile-directory=Profile\ 1 --incognito

Observe the backslash\ in Profile\ 1 to indicate the folder name includes a space.

2
  • 2
    Thanks so much for the detailed information. This works for me! One question, how do I know which user name corresponds to "Default", "Profile 1" and so on?
    – user69715
    Jan 19, 2016 at 19:24
  • I can only recommend that you press Alt+F2 and enter the command: google-chrome-stable --profile-directory=Profile\ X. The X being anyone of the values under ~/.config/google-chrome/. Trial and error is the quickest option I can find.
    – Torrien
    Jan 22, 2016 at 4:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.