Fix multiple launcher icon issue in Ubuntu unity

I’m so glad I found out how to fix this, because it’s an issue that just kept popping up every now and then.

The issue is this: for some applications, especially (but not necessarily) after upgrades, Unity somehow decides to spawn a new icon every time the app is launched. Thus, you end up with two identical (or in the case of upgrades, very similar) versions of the icon in the Unity launchbar, with the additional annoyance of having one work as a window switcher, and the other working as a new launcher.

Here’s how to fix that.

1. Locate your application’s .desktop file

In Ubuntu this is either inside ~/.local/share/applications or inside /usr/share/applications.

One problem you may have is that you have more than one .desktop file for the same application. If that is the case, remove one (probably the older one).

The .desktop files don’t necessarily match the application name that’s shown when you hover on the launcher (wonderful design idea, duh), so you might need to use grep to find the file.

For example, to find my PyCharm launcher, I had to execute

ls ~/.local/share/applications | grep -i charm

which returned jetbrains-pycharm.desktop, the file that I was looking for.

Removing duplicate .desktop files might be enough to solve the issue, so try launching your app to see if that fixed it. Otherwise, read on.

2. Find your application’s WM_CLASS

This was the core of the issue in my case. To match a window to an application, Unity looks for the window’s WM_CLASS.

To find what your application’s WM_CLASS is, launch your app and run this in a terminal (using a small window for the terminal, leaving your app visible in the background, you’ll see why in a moment):

xprop WM_CLASS

your mouse cursor will turn into a crosshair, and you must click anywhere on your application’s window. You will find something like this in your terminal:

WM_CLASS(STRING) = "sun-awt-X11-XFramePeer", "jetbrains-pycharm-ce"

(this is the output for PyCharm Community Edition). Your WM_CLASS is the most specific string in the list (use your intuition, in this case jetbrains-pycharm-ce is obviously about PyCharm, whereas the other seems to be related to all Java apps in general).

3. Set your application’s WM_CLASS in the .desktop file

Open your .desktop file from Step 1 with a text editor, and either add (if it’s not there already) this line to the bottom, or replace its previous value with the WM_CLASS string from Step 2:

StartupWMClass=jetbrains-pycharm-ce

replacing jetbrains-pycharm-ce with your WM_CLASS, of course.

4. Profit

That’s it! Close all your application windows, and relaunch your app. This time, after you launch the app, you should only have one icon 🙂

Advertisements

Disable annoying show-desktop effect on Compiz after uninstalling Macbuntu

Some weeks ago I decided to give Macbuntu a try just to see how OS-X-ey my Ubuntu may look. Turns out it can really look pretty much like a Mac, with all of its fancy animations on every window maximize/minimize event, side-by-side windows display, mouse-sensible corners and everything.

Being the geek that I’m told I am though, I grew tired of all the swishes and fsshhes pretty quickly, so I decided to remove them altogether. Bad news is, you can’t just run uninstall.sh as they tell you to.

  • First of all, I didn’t have any uninstall.sh script on my Macbuntu folder. I didn’t want to download the whole 42MB archive from here, so I googled a little more and found this script on this (Italian) blog.
  • After running the script, Macbuntu was gone but.. so were all my themes!
  • I reinstalled gnome-themes-selected, gnome-themes-ubuntu and light-themes (cause I use Ambiance) packages using Synaptic and restarted X. My themes were back again, but still the show-desktop animation à la Mac OS was enabled, with every open window flailing its way (as in wacky-waving-inflatable-arm-flailing-tube-men) towards the bottom-left corner of the screen as soon as my mouse cursor touches it.
  • After some more googling, I discovered that the effect (found in compiz-fusion-plugins-extras) is called “magic lamp”, and can be disabled by going into System/Preferences/CompizConfig Settings Manager/Effects/Animations Plus and removing the entry for Magic Lamp from every event it’s attached to.

Now my beautiful, clean Gnome desktop is back! 🙂

BTW, I use an Emerald theme called “The Empire strikes back” which is really cool. You can find it here.