Icon missing when application is launched

What will most probably solve your problem is to do the following:

  1. Open the application
  2. When it is running, open a terminal and type:

    xprop WM_CLASS
    
  3. Then click on the open application window.

  4. The output will look like (example gedit):

    WM_CLASS(STRING) = "gedit", "Gedit"
    
  5. Use the first part (in this case would be gedit), to compose a line in your .desktop file:

    StartupWMClass=<string>
    

    (replace <string> with the actual (first part of the) output of xprop WM_CLASS, e.g. StartupWMClass=gedit)

Now try again (you might have to log out / in), most likely the application will appear in the launcher under its own icon.

Explanation

  • When an application starts up correctly from a launcher (.desktop file), but another icon appears with only a generic icon (question mark), it is most likely that the application window and the launcher do not connect for some reason, and the launcher does not recognize the application's window as "his". This is often the case when a script or a non- standard application (-command) is used. In those cases the StartupWMClass= line is often the solution.

for me xprop|grep WM_CLASS gave WM_CLASS(STRING) = "sun-awt-X11-XFramePeer", "jetbrains-pycharm-ce" (I was having this issue with pycharm for python)

It was the sun-awt-X11-XFramePeer that I needed as the string in my .desktop file (without quotes) - Thanks!


After putting icons into the right place, you should simply restart xserver (logout and login back).
Also try to update icon cache (simply paste code below into terminal):

for d in ~/.icons/*; do gtk-update-icon-cache -f $d; done
for d in /usr/share/icons/*; do sudo gtk-update-icon-cache -f $d; done