Share via:

How to Avoid Duplicated Icons in Dash and Unity

This simple tutorial shows how to solve the problem with duplicated icons created by custom .desktop files.

1543 views

Edited: 2017-06-13 13:04

When launching an application from a custom .desktop file, it may result in a duplicated icon showing up in the Gnume's dash or Ubuntu's unity launcher panels. To avoid this problem, we may specify the window class in the launcher .desktop file, we can do this by opening it with gedit.

The Window class of a program can be obtained by typing xprop WM_CLASS in a terminal, then selecting the main window of the program by clicking on it, the window class will then be written out in the terminal, and then we can simply copy and paste it into the launcher.

Note. If the window is not visible simply press alt + tap until it is in focus.

You will need to open the .desktop file in a text editor, and add the following line:

StartupWMClass=[Name_of_Window_Class]

Note. The [Name_of_Window_Class] part should be replaced with the output of the xprop command.

When done, restart the application, and there should now only be one icon visible in dash.

Where to find application launchers

Possible locations for custom launchers are:

  • ~/.local/share/applications
  • /usr/local/share/applications
  • /usr/share/applications

Comments

Peter

Nope. Didn't work for me.

Output of xprop: WM_CLASS(STRING) = "sun-awt-X11-XFramePeer", "NetBeans IDE 8.2"
Content of .desktop file (for Netbeans):

[Desktop Entry]
Encoding=UTF-8
Name=NetBeans IDE 8.2
Comment=The Smarter Way to Code
Exec=/bin/sh "/home/peter/netbeans-8.2/bin/netbeans"
Icon=/home/peter/netbeans-8.2/nb/netbeans.png
Categories=Application;Development;Java;IDE
Version=1.0
Type=Application
Terminal=0
StartupWMClass="sun-awt-X11-XFramePeer", "NetBeans IDE 8.2"

Starting NetBeans still creates a duplicate icon.

Oh well! It was a nice try.

Juan Jimenez

Works for me!


[Desktop Entry]
Type=Application
Name=Apache NetBeans IDE 9.0
StartupWMClass=Apache NetBeans IDE 9.0
Exec=/opt/netbeans/bin/netbeans
Icon=/opt/netbeans/nb/netbeans.icns
Terminal=False

Curt

Worked for me in Eclipse CDT (Neon). Thank You!

Here is my eclipse-cdt.desktop file:

[Desktop Entry]
Version=1.0
Name=Eclipse CDT
Comment=C/C++ IDE
Type=Application
Categories=Development;IDE;
Exec=/opt/eclipse/cdt/latest/eclipse
Terminal=false
Icon=/opt/eclipse/cdt/latest/icon.xpm
Name[en_US]=Eclipse
StartupNotify=true
StartupWMClass=Eclipse