47

I have a Google Chrome icon in Plank. After an update to Google Chrome, a second fuzzy icon appears every time the browser is opened:

enter image description here

How can I fix this?

7
  • This happens in Luna too. I think the Freya tag is unwarranted.
    – waldyrious
    Commented Jun 30, 2015 at 19:00
  • Then we add the luna tag too :)
    – Gabriel
    Commented Jun 30, 2015 at 19:00
  • I agree with @Tim
    – waldyrious
    Commented Jun 30, 2015 at 19:02
  • Fair enough, removing both tags then (Tim was faster).
    – Gabriel
    Commented Jun 30, 2015 at 19:03
  • @Daniel, the retitling of the question is IMO a bad move as it makes this question harder to find for those with the specific issue of the chrome icon (when looking at a list of search results, the title is the most important clue to quickly filter the results). Please reconsider, or at least let's discuss first in the comments or meta.
    – waldyrious
    Commented Oct 14, 2015 at 19:21

7 Answers 7

46

Edit Oct 14th, 2015

Apparently this issue is fixed in Google Chrome v46. If you are still experiencing it, try upgrading Chrome.


To fix this issue, you can follow the steps outlined in this post:

  1. Make a copy of the .desktop file of Google Chrome to your user's local applications folder:

    cp /usr/share/applications/google-chrome.desktop ~/.local/share/applications
    
  2. Open the copied .desktop file with:

    scratch-text-editor ~/.local/share/applications/google-chrome.desktop
    
  3. Once the file opens, paste the following line:

    StartupWMClass=Google-chrome-stable
    

    somewhere for each of the three sections in the file: [Desktop Entry], [NewWindow Shortcut Group] and [NewIncognito Shortcut Group] (for example, at the end of each section).1

  4. Save and close the file.

  5. Remove the Google Chrome launcher from Plank (unselect Keep in dock, if it's checked), and open the browser using the Slingshot launcher.

  6. Select Keep in dock for the new Google Chrome icon that appears in Plank (should appear not fuzzy).


1 If you are fixing this for a different program, you can find out which WM_CLASS your window has got when you type in a terminal:

xprop WM_CLASS

and then click on the window. In case of Google Chrome the output is as follows:

WM_CLASS(STRING) = "Google-chrome-stable", "Google-chrome-stable"

For a different application it will be different, so the line to add will be like:

    StartupWMClass=Name-of-application

After adding the line, be sure you removed the previous launcher then start the application and right clicking on its dock icon check 'Keep in dock': just dragging & dropping the .desktop file onto the dock may still lead to a second launcher/icon appearing in the dock.

8
  • 4
    I would suggest to make a copy of the .desktop file to your users local application folder and edit this file instead: cp/usr/share/applications/google-chrome.desktop ~/.local/share/applications. It prevents of overwriting your changes by any future chrome update.
    – Rafael
    Commented Jun 30, 2015 at 18:55
  • @Rafael please make that a separate answer, so we can upvote that solution as preferable (or edit the question to integrate your method). An update-proof solution is definitely more desirable.
    – waldyrious
    Commented Jun 30, 2015 at 19:02
  • I can add the suggestion, seems like a reasonable one. Since I haven't tried it, a question first: will this new .desktop file be the default one used when launching the browser from Slingshot? If it is, I can add the cp line between points 3. and 4.
    – Gabriel
    Commented Jun 30, 2015 at 19:05
  • 2
    @Gabriel Yes, every duplicate .desktop file in your local applications folder will be prefered. I've already edited your answer...
    – Rafael
    Commented Jun 30, 2015 at 19:11
  • I'm not sure directing users to Terminal first thing is best. Perhaps alternative directions using the Files app could be provided? There're also a few issues here: Searching the app launcher will now show two Chrome entries, and the user will no longer get an up-to-date Chrome launcher (meaning if Google ever changes something like translations or new launcher integration the user will not get it and will not know why). It might be relevant to mention this is an issue with Chrome itself and has been confirmed in its bug tracker: code.google.com/p/chromium/issues/detail?id=378881 Commented Sep 14, 2015 at 18:55
16

This is an issue with Google Chrome that affects multiple OSes and has been confirmed in Google's issue tracker. That said, you can work around it in elementary OS.

Workaround:

1. Copy the app launcher

  1. Open the Files app, click in the top location bar, and type /usr/share/applications/.

Screenshot of Files at the right location

  1. Find the Google Chrome launcher and copy it (secondary/right-click > Copy, or Ctrl+C).
  2. Click in the top location bar and type ~/.local/share/applications, then paste (secondary/right-click > Paste, or Ctrl+V) the Chrome launcher.

2. Modify the new launcher

  1. Secondary/right-click the new Google Chrome launcher in your ~/.local/share/applications folder and choose Open with > Other Application.
  2. Choose Scratch from the list, or if it's not there, choose View All Applications and then choose Scratch and click Select.
  3. In the file that opens, find each line that begins with Exec= and type StartupWMClass=Google-chrome-stable on a new line below each instance.

Screenshot of Scratch editing the launcher

  1. Close the file (it should save automatically unless you have changed Scratch's default settings).

3. Re-add it to your dock

  1. Remove any existing Chrome launcher from your dock by secondary/right-clicking it and unchecking Keep in Dock, or simply drag the icon off of the dock.
  2. Open the app launcher (Applications) and drag the Chrome icon to your dock, or secondary/right-click it and select Add to Dock.

Caveats:

  1. This has been proven to work now, but could possibly break with a future update of Google Chrome.
  2. Ideally Google will fix the issue and push out an update, at which point the Google Chrome launcher at ~/.local/share/applications/ could be deleted.
  3. You will continue to receive updates to Google Chrome, but will no longer receive updates to the Google Chrome launcher itself. This shouldn't be an issue, but means any new translations or features Google adds to the launcher won't show up for you unless you repeat these steps.
8

Here's a one-liner to fix the issue as described in Gabriel's answer:

cp /usr/share/applications/google-chrome.desktop ~/.local/share/applications && sed --in-place --regexp-extended 's/^(\[[A-Za-z ]+\])$/\1\nStartupWMClass=Google-chrome-stable/g' ~/.local/share/applications/google-chrome.desktop


To unpack and explain this command line a bit: first it copies (cp) the global .desktop file to your user directory, since the latter overrides the former for the current user, and isn't changed by package upgrades.

If that operation succeeds (&&), it then uses the sed command to do a find-replace operation, which follows the pattern sed 's/<find>/<replace>/<flags>' (where s stands for "substitute"). Step by step, here's what that sed command says:

  1. find all lines that start with [ and end with ] (that's the ^(\[[A-Za-z ]+\])$ part — RegExr or Regex101 can explain it much better than I could here :))

  2. replace them with themselves (\1) followed by a newline (\n) and the string "StartupWMClass=Google-chrome-stable"

  3. and do this to all of them, i.e. using the global flag (/g), and directly editing the file (--in-place) rather than outputting to the shell. The last argument is the filename to pass to sed, which is the file the cp command has just created.

6
  • Perhaps explain a bit what the line does? Specially the sed part can be confusing to new users.
    – Gabriel
    Commented Aug 20, 2015 at 13:21
  • @Gabriel yeah, that was just laziness on my part :) I originally intended to expand this answer like I did with this one, but I never got around to do it. I'll edit the question to add the details.
    – waldyrious
    Commented Aug 20, 2015 at 14:48
  • 1
    @Gabriel thanks fro prompting me to expand the answer. I've now added details and I agree it's a much better answer. I also cleaned the command up a bit, by changing the cryptic -i to the spelled out --in-place, removing the unnecessary -e, and using \+ rather than \{1,\} (I had tried plain + before and it didn't work, and it didn't occur me to try escaping it :P)
    – waldyrious
    Commented Aug 20, 2015 at 15:40
  • Actually, I just learned that the regex can be made even simpler, by using the -r option (which I spelled out here for clarity purposes) to avoid escaping \+, \( and \). Re-edited the question. It keeps getting better! :D
    – waldyrious
    Commented Aug 20, 2015 at 16:14
  • Really not a fan of providing cryptic one-liner Terminal commands to users. It encourages copy-pasting directly into Terminal, which is a bad habit and potentially wildly insecure. Commented Sep 14, 2015 at 19:16
7

This is a non-Chrome specific answer.

Many questions about other applications than Google Chrome have been marked as duplicate of this one, although this is about Google Chrome, because the definitive answer contains a general non-Chrome specific solution.

I had a problem that seemed a duplicate (and that I was about to post as a separate question) about other applications and I couldn't initially see the solution there in the middle of a large text about Google Chrome. Also, that solution was not in fact working for me (see below, case 3). So, I think that it could be useful to have a clear separate answer -- to which all those closed questions marked as duplicate (and others that will suffer the same faith) can be referred.

Also, there are variations of this problem

  1. the second icon is fuzzy, as in this Google Chrome question

enter image description here

  1. the second launcher of the same application is not just fuzzy, but is completely lacking an icon/image, like here

enter image description here

  1. the second icon is not fuzzy at all, but identical to the first

enter image description here

and posting those as separate questions may also lead to them being closed as duplicate; various way of dealing with these variations will be integrated in this answer.


So, the main source is the definitive answer.


The launchers in the Plank dock correspond to .dockitem files located in ~/.config/plank/dock1/launchers/. Each .dockitem file corresponds to a .desktop file. Such files (which are themselves 'launchers', as they can be executed to start an application) are usually located in /usr/share/applications or in ~/.local/share/applications (in this case the application can be found and launched with the Applications/Slingshot launcher), but they can be put in other places, thus avoiding them being changed back by an update (the downside of this being they cannot be seen in the panel Applications/Slingshot launcher/finder) To both find them in the Slingshot and keep them after update, ~/.local/share/applications is the best location.


[Case 1 - where the second icon is identical to the first, but fuzzy]

The solution in the main answer is to edit in a text editor the .desktop file that launches the application. That should fix the problem no. 1 above.

The idea is to add a line like

 StartupWMClass=Name-of-application

To find the proper form of Name-of-application, start your target application and then open terminal and run

xprop WM_CLASS

The cursor becomes a cross, click the window of your target application.

In the terminal you should see something of the form

WM_CLASS(STRING) = "Name-Of-Application", "name-of-application"

Add that name to the line and paste the line in the .desktop file somewhere for each of the three sections in the file: [Desktop Entry], [NewWindow Shortcut Group] and [NewIncognito Shortcut Group] (for example, at the end of each section).


[Case 2 - where the second icon is not identical to the first, but is just a generic icon that lacks an image]

like here

The OP of that question has posted this in a laconic answer: Finally, there is a simple way to fix this: simple change the icon file from webide.png to webide.ico, or using this useful app to edit the menu: https://apps.ubuntu.com/cat/applications/precise/alacarte/.

I cannot verify, but it looks very far from the solution accepted under this question to which that was flagged as duplicate. (So, I flagged that one for re-opening.)


[Case 3 - where the second icon is completely identical to the first]

This happened to me when I have created a .desktop file to launch a static beta version of DeadBeeF, the stable (non-static) version of which was installed at system level, and then dragged & dropped that file onto the dock. When starting the program from the dock launcher a second identical icon appeared.

That second icon had the same option upon right-click as the first. Checking 'Keep in dock' for the second icon/launcher and un-cheking that for the first, and then launching the application from it, there would be no second icon but the stable version would start instead of the static one. Keeping both on the dock and starting the application from both, alternatively, they will start each its own version, but only the launcher of the system-level installed version will be underlined in Plank.

Indeed, at this point, looking in ~/.config/plank/dock1/launchers/, one of the .dockitem files present would be referring to the .desktop file in usr/share/applications launching the main stable version.

The only way to avoid the second icon appearing while keeping the icon/launcher of the static build was to delete the .desktop file in usr/share/applications that was referring to the stable version installed at system level (also, that .desktop file shouldn't be present in ~/.local/share/applications) and then add again to Plank the launcher for the static build.

This case was the result of the fact that a version of the same application was installed at system level. Un-installing that from system level (completely, or using a static build for that too) would have also fixed the problem.

1
  • Thanks! I learned that some flatpack/gnome software is located in /home/<user>/.local/share/flatpak/exports/share/applications by looking into the directory you mentioned: ~/.config/plank/dock1/launchers/. In the .desktop file I followed your instructions, I even added the entries: [NewWindow Shortcut Group] and [NewIncognito Shortcut Group] because for the little game Aislerot (patience, freecell etc) these entries weren't in the .desktop-file. After I restarted the computer everything is OK: no second fuzzy icon anymore!
    – Silex
    Commented Oct 29, 2021 at 14:22
3

After upgrading to version 46.0.2490.71 and above you may experience this problem again. This problem occurs because WM_CLASS has been changed on google-chrome.

Based on waldyrious's answer, fix it easiest way:

cp /usr/share/applications/google-chrome.desktop ~/.local/share/applications && sed --in-place --regexp-extended 's/^(\[[A-Za-z ]+\])$/\1\nStartupWMClass=google-chrome/g' ~/.local/share/applications/google-chrome.desktop

1
sudo scratch-text-editor /usr/share/applications/google-chrome.desktop

You'll find a line

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

I changed mine to

Exec=google-chrome %U

After restarting Google Chrome the icon was all shiny and nice :)

Hope this helps.

1
  • 5
    Your change won't survive the next google chrome update. It's better to copy the .desktop file to ~/.local/share/applications and change this copy instead.
    – Rafael
    Commented Aug 20, 2015 at 11:30
-3

A work around is installing Google-chrome-beta no problem with that one also a little newer features

1
  • 3
    Or just install chromium-browser ;-)
    – png2378
    Commented Jul 23, 2015 at 19:56

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