Launcher duplicate iconless icon

As from the screenshot below, there is a duplicate icon of the xfig program. Sometimes with different programs same thing happens.

enter image description here

Any ideas how to solve this?


There can be different causes for an application icon, to show up with a question mark (or otherwise incorrectly) in the Unity launcher.

To start with: application icons are defined in the .desktop file of an application. These .desktop files are (normally) stored in /usr/share/applications, or ~/.local/share/applications

Common causes are:

  • The link to the icon, as defined in the .desktop file of the application, is broken; the icon does not exist or is in the wrong path. effect: the application shows up in the launcher with an incorrect icon (grey question mark).
  • The application is represented by more then one .desktop file. That is: there is more then one .desktop file on your system, with a command to run the application in its first Exec= line. effect: many times, Dash shows more than one (correct) icon, representing the same application. When the application is locked to the launcher, sometimes (or always) if the application runs, another icon appears (the same or slightly different).
  • For various reasons, sometimes the application and the launcher icon are not connected to each other. Although the application is started by the (command in) the .desktop file, the application is not recognized by the .desktop file as "his" application effect: If the application is locked to the launcher, it shows a correct icon, but another one appears when the application runs (grey question mark). If the application is not locked to the launcher, the application is represented by an incorrect icon in the launcher if it runs. (grey question mark, since the binary file has no icon of itself).

In the case of Xfig, the last is the case. You can fix the issue in by adding the following line to the .desktop file:

StartupWMClass=xfig
  • open the application's file (xfig.desktop) with gedit:

    gksu gedit /usr/share/applications/xfig.desktop (you may have to install gksu first)
    
  • Add the line:

    StartupWMClass=xfig
    

Now Xfig will run under its own icon:

enter image description here