2

(Ubuntu 18.04) Is there a command to open an executable WITH a given icon? I'll give more background. I'm trying to create multiple google chrome "users" (NOT the "People" tab, I need each user to have it's own set of people). I know you can do this, and I did, by first running

mkdir ~/.config/google-chrome-Theo

and

mkdir ~/.config/google-chrome-Teddy

Then making a Desktop executable that runs

google-chrome --user-data-dir=$HOME/.config/google-chrome-Theo

and another one that runs

google-chrome --user-data-dir=$HOME/.config/google-chrome-Teddy

That way, when I run the "Theo" executable, I get Theo's suite of People, bookmarks, etc. but when I run the "Teddy" executable, I get Teddy's People and bookmarks. The issue with this is that I can change the icon of each of the Desktop executables, by going into their Properties menu, but I can't change the icon of the chrome instances that pop up. That is, when I open Theo and Teddy's chromes at once, there are two, generic chrome icons, and I have to search to find the one I want. Is there a command to open an executable WITH a given icon?

EDIT: I tried fra-san's answer, and it didn't seem to work for me. I'll clarify what I tried: I ended up with these two desktop files:

  1. Desktop/Chrome-Theo.desktop with this content:

#!/usr/bin/env xdg-open [Desktop Entry] Version=1.0 Terminal=false Type=Application Name=Google Chrome Exec=/opt/google/chrome/google-chrome --user-data-dir="/home/theo/.config/google-chrome-Theo" --class=theo Icon=/home/theo/Icon-Blue.png NoDisplay=true StartupWMClass=theo

  1. Desktop/chrome-teddy.desktop, with this content:

#!/usr/bin/env xdg-open [Desktop Entry] Version=1.0 Terminal=false Type=Application Name=Google Chrome Exec=/opt/google/chrome/google-chrome --user-data-dir="/home/ubuntu/.config/google-chrome-Teddy" --class=teddy Icon=home/teddy/Icon-Red.png NoDisplay=true StartupWMClass=teddy

However, when I open them, they still show the default chrome icon in the sidebar. Did I mess up somewhere?

EDIT 2: I just realized that the two desktop executables are opening the same user of chrome... I bookmarked a page on the Theo chrome, and when I opened the Teddy one, it had that same bookmark. I'm really confused at this point.

7
  • Welcome on U&L! By "Desktop executables" are you meaning the .desktop files? They have an Icon key that lets you set the "Icon to display in file manager, menus, etc ..."
    – fra-san
    Commented Jan 13, 2019 at 18:02
  • 1
    Also, about your "there are two, generic chrome icons": where? Are you referring to the icons in the application top bar (as the answer by sudodus is showing)? Or to the icons in the taskbar at the bottom of the screen?
    – fra-san
    Commented Jan 13, 2019 at 18:25
  • @fra-san I mean the icons on the left of the screen.
    – Theo
    Commented Jan 13, 2019 at 20:59
  • 1
    Ok. I guess you are referring to the icons in the dash (I'm not on Ubuntu/GNOME). I suggest you to edit your question, adding this information and, for clarity, your Ubuntu version. (I can think of at least three or four different places where an application icon is shown, and most of them have their specific settings). This will help others to help you.
    – fra-san
    Commented Jan 13, 2019 at 22:26
  • On Edit 2: are you sure you did not sign in to the same Google account on both your Chrome profiles? Maybe your bookmarks are being synchronized. You should probably make your tests with two new, empty user data directories, without copying/moving existing profiles.
    – fra-san
    Commented Jan 15, 2019 at 9:02

1 Answer 1

1

Assumptions

I will assume that: you are on Ubuntu 18, your desktop environment is GNOME 3, you are using google-chrome-stable.
Also, I will assume that the icons you are referring to are those in GNOME's dash (actually, it is Ubuntu Dock, which as far as I can tell is a fork of dash, but I'm currently unable to link to any meaningful documentation). Its default behavior is to group together multiple instances of Chrome. Thus, finally I'm assuming that you want distinct icons for distinct Chrome profiles in Dock.

Solution

Basically, the steps you need to reproduce are explained in my answer to this question. That won't be enough, though, presumably because of this bug - which makes Google Chrome ignore the --class option unless the --user-data-dir option is also specified (and distinct directories are used).

You will need two things:

  1. Some edits to your desktop files;
  2. Two distinct Chrome user data directories.

Point 2: fortunately you already have them: ~/.config/google-chrome-Theo and ~/.config/google-chrome-Teddy.

Point 1: I don't have enough details about your desktop files, so here I'm creating them from scratch.
By default, the location of per-user desktop files is ~/.local/share/applications.
Thus, I create:

  1. ~/.local/share/applications/chrome-theo.desktop, with this content:

    #!/usr/bin/env xdg-open
    [Desktop Entry]
    Version=1.0
    Terminal=false
    Type=Application
    Name=Google Chrome
    Exec=/opt/google/chrome/google-chrome --user-data-dir="/home/your_user/.config/google-chrome-Theo" --class=theo
    Icon=icon_for_theo
    NoDisplay=true
    StartupWMClass=theo
    
  2. ~/.local/share/applications/chrome-teddy.desktop, with this content:

    #!/usr/bin/env xdg-open
    [Desktop Entry]
    Version=1.0
    Terminal=false
    Type=Application
    Name=Google Chrome
    Exec=/opt/google/chrome/google-chrome --user-data-dir="/home/ubuntu/.config/google-chrome-Teddy" --class=teddy
    Icon=icon_for_teddy
    NoDisplay=true
    StartupWMClass=teddy
    

Replace your_user in the paths with your actual username.
Replace icon_for_theo and icon_for_theddy with:

  • The full path to the icon files you are going to use; OR
  • The name, without extension, of the icon files if you are making them available system-wide in /usr/share/icons/hicolor/.

The second option is much more complex to set up, but it allows you to have variously sized icons. Refer to this answer on Ask Ubuntu for further information - it ultimately links to the Icon Theme Specification by freedesktop.org.

How does it work:

  • The --class= option gives two distinct WMCLASSes to the two Chrome instances, making them non-groupable in Dock;
  • The StartupWMClass= sets a link between the open Chrome windows and the desktop entries that launched them, letting them keep their custom icons in Dock;
  • Due to the bug mentioned above, the --user-data-dir= option and the two distinct user data directories are needed for the first two points to be effective.

Notes and troubleshooting

Tested with: live Ubuntu 18.04 LTS, Xorg session, google-chrome-stable 71.0.3578.98-1.

Borrowing from the comments to my aforementioned answer:

  • It is advisable to test this kind of configurations on a clean system: at least, new Chrome profiles and user data directories; at best, a dedicated user (possibly created solely for testing purposes).
  • xprop can be used for checking if the --class option is being honoured:

    ## This example uses chromium instead of Google Chrome!
    ## With default settings:
    $ xprop WM_CLASS
    WM_CLASS(STRING) = "chromium", "Chromium"
    
    ## With --class=test_class
    $ xprop WM_CLASS
    WM_CLASS(STRING) = "chromium", "test_class"
    
1
  • This didn't work for me, I still got the default chrome icons. (I updated my question to reflect what I tried).
    – Theo
    Commented Jan 15, 2019 at 4:32

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .