Thursday, April 14, 2016

unity - Icon missing when application is launched


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


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=

    (replace 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.


No comments:

Post a Comment

11.10 - Can't boot from USB after installing Ubuntu

I bought a Samsung series 5 notebook and a very strange thing happened: I installed Ubuntu 11.10 from a usb pen drive but when I restarted (...