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:
How can I fix this?
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:
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
Open the copied .desktop file with:
Once the file opens, paste the following line:
somewhere for each of the three sections in the file:
[NewWindow Shortcut Group] and
[NewIncognito Shortcut Group] (for example, at the end of each section).1
Save and close the file.
Remove the Google Chrome launcher from
Keep in dock, if it's checked), and open the browser using the
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:
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:
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.
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.
~/.local/share/applications, then paste (secondary/right-click > Paste, or Ctrl+V) the Chrome launcher.
~/.local/share/applicationsfolder and choose Open with > Other Application.
StartupWMClass=Google-chrome-stableon a new line below each instance.
~/.local/share/applications/could be deleted.
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:
replace them with themselves (
\1) followed by a newline (
\n) and the string "StartupWMClass=Google-chrome-stable"
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.
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
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
.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
To find the proper form of
Name-of-application, start your target application and then open terminal and run
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]
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.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.
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
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