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:
scratch-text-editor ~/.local/share/applications/google-chrome.desktop
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
Save and close the file.
Remove the Google Chrome launcher from Plank
(unselect Keep in dock
, if it's checked), and open the browser using the Slingshot
launcher.
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.
cp/usr/share/applications/google-chrome.desktop ~/.local/share/applications
. It prevents of overwriting your changes by any future chrome update.
Slingshot
? If it is, I can add the cp
line between points 3. and 4.
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.
/usr/share/applications/
.~/.local/share/applications
, then paste (secondary/right-click > Paste, or Ctrl+V) the Chrome launcher.~/.local/share/applications
folder and choose Open with > Other Application.Exec=
and type StartupWMClass=Google-chrome-stable
on 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:
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 :))
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.
sed
part can be confusing to new users.
-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)
Commented
Aug 20, 2015 at 15:40
-r
option (which I spelled out here for clarity purposes) to avoid escaping \+
, \(
and \)
. Re-edited the question. It keeps getting better! :D
Commented
Aug 20, 2015 at 16:14
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 ~/.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.
/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!
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
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.
.desktop
file to ~/.local/share/applications
and change this copy instead.
A work around is installing Google-chrome-beta no problem with that one also a little newer features
luna
tag too :)