Icon missing when application is launched

9,571

Solution 1

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.

Solution 2

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!

Solution 3

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
Share:
9,571

Related videos on Youtube

clayton
Author by

clayton

Updated on September 18, 2022

Comments

  • clayton
    clayton over 1 year

    I've created an application launcher in /usr/share/applications that launches rdesktop. The file specifies an icon name and I've added the icons to:

    /usr/share/icons/HighContrast/48x48/apps
    /usr/share/icons/HighContrast/22x22/apps
    /usr/share/icons/HighContrast/256x256/apps
    /usr/share/icons/HighContrast/32x32/apps
    /usr/share/icons/HighContrast/scalable/apps-extra
    /usr/share/icons/HighContrast/24x24/apps
    /usr/share/icons/HighContrast/16x16/apps
    /usr/share/icons/hicolor/scalable/apps
    /usr/share/icons/hicolor/128x128/apps
    /usr/share/icons/hicolor/16x16/apps
    

    I then drug the launcher to the taskbar and the launcher with the correct logo is visible in the taskbar. However, when I start the task, a new icon is created in the taskbar, a square with a question mark in the center.

    What icons do I need and where, so that the taskbar displays the correct icon for the application when it is launched?

    The .desktop file contents:

    [Desktop Entry]
    Version=1.0
    Terminal=false
    Icon=mswindows
    Type=Application
    Categories=Network;
    Exec=rdesktop win7shared1 -g 1680x1000
    
    Name=win7shared1
    GenericName=rdesktop
    Comment=Open windows desktop
    
    Keywords=Windows
    StartupNotify=false
    
  • clayton
    clayton over 9 years
    Thanks Jacob. This resolved the problem. For the record, the WM_CLASS string was "rdesktop","rdesktop".
  • Jacob Vlijm
    Jacob Vlijm over 9 years
    @clayton perfect, glad it worked.
  • johndrinkwater
    johndrinkwater over 8 years
    Your step 2 can be reduced, as xprop lets you pass in the atom you want returned, running xprop WM_CLASS is enough
  • Jacob Vlijm
    Jacob Vlijm over 8 years
    @johndrinkwater Absolutely, thanks for the hint. It is more than a year ago, over 14 months is like another person wrote it :). Will edit...
  • johndrinkwater
    johndrinkwater over 8 years
    @jacob-vlijm :) just came across it while researching an awkward xprop behaviour
  • fIwJlxSzApHEZIl
    fIwJlxSzApHEZIl almost 7 years
    I added StartupWMClass=sun-awt-X11-XFramePeer to mine and nothing happened! Is the .desktop file located in the home folder?
  • JHS
    JHS almost 6 years
    This got the icon back for me as long as I use the icon I created on the desktop. Still missing when I search for the application in the dashboard (using the same .desktop file in /usr/share/applications/), but at least I have an option now. Thanks.
  • iBug
    iBug over 5 years
    +1 Good answer! I have two applications that runs the same WM_CLASS. Is it possible to keep their icons separate?
  • Mohamed Elbahja
    Mohamed Elbahja about 4 years
    Thank you, this what I'm looking for.