Why does my custom launcher open under a separate icon?

I’ve created a custom launcher file:

[Desktop Entry]
Comment=Perforce Visual Client

And dragged this file to my launcher. However, when I click the icon, it opens the application under a 2nd, different icon (I click the top one, it opens the application under the bottom one):

launcher icons

The bottom icon isn’t present until after I launch the application using the top P4v icon that I manually added.

Asked By: ctote


If an application produces a second icon, not being a generic one

If an application generates a second icon in the Unity launcher other than a a grey, generic icon, there must be already an (other) existing launcher, calling p4v in its main command:

An application’s .desktop file by definition has a "main" command in the first line, starting with Exec=. This is the command that is run when the icon is clicked in the (Unity) launcher. Apart from that, a .desktop file can have one or more shortcut- sections, available when you right-click on the representing icon in the Unity launcher.

Multiple .desktop files calling the same application in their main command

The symptoms you are experiencing can happen when more than one .desktop file in either /usr/share/applications or ~/.local/share/applications have the same ("main-") command in their first Exec= line, but the files are differently named.

P4v by default should install (and probably has installed) a .desktop file, named p4vasp.desktop in /usr/share/applications.

How to fix
Your problem should be fixed if you remove your own (probably local) .desktop file, then run p4v from Dash and pin it to the launcher.

What if you want to customize the existing launcher?

If you want to change the .desktop file’s behaviour or e.g. its icon:

  • copy the file from /usr/share/applications to ~/.local/share/applications
  • don’t change the file’s name
  • open the file in gedit (drag it over an opened gedit window) and make the changes you’d like
  • log out and back in, the local version of the .desktop file will overrule the global one.

To revert, simply remove the local one, log out and back in.

Related to this post

Answered By: Jacob Vlijm

Solution that worked for me on ubuntu 18.04 when struggling with getting an AppImage added to my favorites. This solution is summarised from

  1. Launch application with duplicate icon

  2. Get window class of application by executing

     xprop WM_CLASS
  3. Click on main window of application. You should then receive output of the form

     WM_CLASS(STRING) = "some-thing", "different-thing"

Both some-thing and different-thing should work.

  1. Find <application-name>.desktop file (likely in ~/.local/share/applications)

  2. Add the following line to desktop file and replace Name_of_Window_Class with either some-thing or different-thing:

  3. Start/Restart the application

Answered By: Amanda
Categories: Answers Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.