69

I have downloaded Aptana Studio 3 and created the following launcher item for using Alacarte:

file: alacarte-made.desktop

[Desktop Entry]
Comment=
Terminal=false
Name=Aptana Studio 3
Exec=AptanaStudio3
Type=Application
Icon=/opt/Aptana-Studio-3/icon.xpm

Then, when I add the icon to the favorites and opens the Aptana Studio 3 I get two icons for it, one for launching new instances, and one for the currently running instance as per the following screenshot:

enter image description here

How do I force the application to use the same icon added to the favorites?

pomsky
  • 68,507
malhobayyeb
  • 1,422
  • Can you please specify how you installed Aptana? From the official site all I can see is a standalone zip file. (something like portable applications in windows). – hytromo Jan 29 '14 at 06:31
  • Yes, that was it. – malhobayyeb Jan 29 '14 at 06:41
  • So, how did it end up in /opt? Also, is it on your $PATH? How by specifying only AptanaStudio3 in your desktop file it is able to run? – hytromo Jan 29 '14 at 06:42
  • 1
    I have done it, thank you. I have created a Sym Link in /usr/bin to /opt/.../aptana It was just a mater of naming issue. I had to name the .desktop and bin and link just the same :) – malhobayyeb Jan 29 '14 at 06:44
  • 3
    Please answer in detail below how you managed to solve your problem :) (I don't know, I only asked you some questions) – hytromo Jan 29 '14 at 06:46
  • So, have you solved the problem with duplicate icons? If so, please create a detailed answer. – Viktor K Feb 02 '14 at 10:25
  • I will try to do so :) I am busy these days... – malhobayyeb Feb 05 '14 at 05:00
  • This works and fixed the same problem I had with popcorn-time favorite I added to the gnome bar on ubuntu 17.04 – miguelmorales85 Mar 18 '18 at 14:45

4 Answers4

104

To save sifting through the thread mentioned by @earthmeLon, you need to do the following:

  1. Launch the application
  2. Fire up a terminal and run xprop WM_CLASS. Click on the window of the the application that is running with a duplicate icon.
  3. You'll get some output like WM_CLASS(STRING) = "Navigator", "Firefox". Choose one of the classes, eg Firefox in this example
  4. Add the class as the value of StartupWMClass in the .desktop file. For example, StartupWMClass=Firefox
  5. Save the .desktop file, close the application and re-open it. There should now only be 1 icon in the launcher
Greeso
  • 125
  • 3
    For those having the same issue on GNOME you can use MenuLibre: When editing the corresponding entry you will find a field for setting StatupWMClass in the list that shows up when clicking the "Advanced" button – conceptdeluxe Dec 10 '15 at 13:45
  • If someone is trying to handle an issue with mendeley executable, make sure to also edit .../bin/install-mendeley-link-handler.sh, because it overrides .desktop file on each run – MInner Nov 11 '17 at 00:26
  • 1
    TLDR; .desktop filename = WM_CLASS(STRING) last item but lowercased. Details:* I had to solve this issue while creating "Firefox Developer edition" shortcut. Naming the file "firefox.desktop" simply shadowed the standard firefox icon. Using xprop WM_CLASS and clicking the window returned WM_CLASS(STRING) = "Navigator", "Firefox Developer Edition". In the end I renamed my .desktop file as follows: mv ffde.desktop "firefox developer edition.desktop". (Another issue though, I can not right-click » addToFavorites on the icon from the gnome dock extension) – Stphane Jun 24 '18 at 10:59
  • 1
    If you don't want to / can't to modify the original .desktop file into the /usr/share/applications folder, you can copy the file to your local folder, ~/.local/share/applications, and modify the file here. So you will have a system-wide original file (probably provided by the developer/distribution) and a customized file which overrides the original file in the gnome-shell applications panel. Copying to your local folder is desirable as the file into /usr/share/applications can be reversed in the next package update. – Vinícius A. Jorge Jun 27 '18 at 22:04
  • Several apps don't have WM_CLASS, or at least xprop doesn't show it. Can it be done with another property? For example a regular expression on WM_NAME? – jws Apr 03 '19 at 13:03
  • 1
    Accept this answer already :) – Greeso Feb 05 '20 at 16:52
  • Was suffering from this for so long. This comment did it for me. Thank you! – J.J Feb 05 '20 at 22:27
  • 1
    No. Useless in Ubuntu 20 – funicorn Nov 06 '20 at 02:08
  • It still works in Gnome 3.38. – Sebastian Simon Nov 13 '20 at 00:10
  • Works ok on Ubuntu 20.04. Thanks! – Juan Ignacio Barisich Jul 02 '21 at 12:58
  • 1
    Thanks for saving me twice. I would have gave you another up-vote, but I unfortunately can't. – Greeso Mar 01 '22 at 19:06
  • What a wonderfully simple fix! I'll note, though, that when the instructions say "click on the window", they mean on the window. Simply switching to the application (e.g. by clicking on its app icon) isn't enough to trigger xprop. – Ben Blank Dec 03 '22 at 21:15
4

StartupWMClass

You can use StartupWMClass to group windows by class.

See this thread for additional information.

earthmeLon
  • 11,247
  • In addition, make sure: (1) There's no other desktop file for the same app, also in "AppEditor" or in "Main Menu". (2) Verify that Exec=/path/to/app is an absolute path. – Noam Manos Mar 30 '20 at 15:54
0

I'm using Ubuntu 22.04.1 LTS and I installed Firefox Developer Edition Version=109.0

I came up with same problem, Here I paste my .desktop code,

Before (Wrong):-

[Desktop Entry]
Encoding=UTF-8
Name=Mozilla Firefox
GenericName=Web Browser
Comment=Firefox Developer Edition
Exec=/opt/firefox/firefox
Icon=/opt/firefox/browser/chrome/icons/default/default128.png
Terminal=false
Type=Application
Categories=Application;Network;WebBrowser;
MimeType=text/html;text/xml;application/xhtml+xml;application/vnd.mozilla.xul+xml;text/mml;
StartupNotify=True
X-GNOME-Autostart-enabled=false
Version=109.0

After (Working):-

[Desktop Entry]
Encoding=UTF-8
Name=Mozilla Firefox
GenericName=Web Browser
Comment=Firefox Developer Edition
Exec=/opt/firefox/firefox
Icon=/opt/firefox/browser/chrome/icons/default/default128.png
Terminal=false
Type=Application
Categories=Application;Network;WebBrowser;
MimeType=text/html;text/xml;application/xhtml+xml;application/vnd.mozilla.xul+xml;text/mml;
StartupNotify=True
X-GNOME-Autostart-enabled=false
Version=109.0
StartupWMClass=firefox-aurora

Now its working correctly.

Hint:-

I tried all the above answers before posting my answer(this),

  1. Launch the application
  2. Fire up a terminal and run xprop WM_CLASS. Click on the window of the the application that is running with a duplicate icon.

When I run xprop WM_CLASS , I can't see any output as mentioned in those answers.

Then how do I solve this?

When I mouse over the additional app icon in taskbar, It displayed firefox-aurora

I just read the application.ini file from firefox installation folder and found RemotingName=firefox-aurora so I copied firefox-aurora name to StartupWMClass=firefox-aurora

In place of firefox-aurora I also tried firefox (because its the executable file name), but it didn't work for me.

-2

I faced this issue when I manually installed Spring Tool Suite 4

Then, after install, I created STS.desktop in following folder of Ubuntu 20