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.

7333 views

Edited: 2019-12-31 06:17

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.

Note. Another cause for duplicated icons can be if you installed both the repository version and the snap version of a program.

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

Tell us what you think:

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

  1. Generate a GPG key that can be used with KWallet.
  2. How to extract and install FileZilla from tar.bz2 in Ubuntu.
  3. About the problem with using sudo with graphical programs in Linux.
  4. Tutorial showing how to configure a VirtualBox Guest VM with HOST-only and NAT adapter, while using the WWW folder from the HOST OS.
  5. My experience with do-release-upgrade is that it rarely breaks anything, so I would say it is generally a safe and reliable way to upgrade Ubuntu.

More in: Ubuntu