Duplicated icons with Unity. Particular case: Matlab

When I run Matlab from its launcher, a second icon will show up. Funny thing is that if I put the mouse on the new icon, the text that appears on it is not the one I have in my .desktop file. So my guess is that the launcher is launching the script but it is not capable of associating it with its icon, so it launches a secondary one.

So far it only happened with Matlab.

I don't know what happened, it was working fine and now it doesn't. I don't feel I have changed anything.

I have the .desktop file in .local/share/launchers. Its code is:

[Desktop Entry]
Type=Application
Name=Matlab
Comment=Matlab
Exec=/usr/local/MATLAB/R2012a/bin/matlab -desktop
Icon=/home/kais3r/.local/share/launchers/Matlab.png
Terminal=false
Categories=Math;IDE;
StartupNotify=true

But I don't think the problem is related to this. Maybe some of the last updates? I don't know.

6 Answers

Add the following line to your .desktop file

StartupWMClass=com-mathworks-util-PostVMInit
1

I had the same problem with Matlab R2013a. I opened .desktop file and found that the content was right except for the fact that there was a blank line between StartupNotify=true and StartupWMClass=com-mathworks-util-PostVMInit. I removed the blank line, restarted matlab, and it worked. Now only one icon appears as expected. Not sure, how it worked!

Here mentions a possible solution (I had the same problem):

In order for icons to appear correctly StartupWMClass needs to be set in the desktop entry. To find it out start MATLAB, run xprop | grep WM_CLASS on terminal and select the MATLAB window.

Add the following line to your .desktop file

StartupWMClass=com-mathworks-util-PostVMInit

For me it worked. The second icon appears only when matlab is starting and there is the little window with written "Matlab: the Language of Technical computing"; then it disappears and only one icon remains.

I've also installed the package matlab-support, maybe it can be useful.

1

Have you tried this?

(Please note of course it's safer just to move the file outside of the directory e.g move it to the desktop before deleting, to ensure it solves the issue first before deleting the file.)

For anyone interested I am posting the solution to the problem. I have run the following command in /usr/share/applications and ~/.local/share/applications to find files containing the entry Matlab regardless of the case; I learned that trick from StackOverflow.

grep -Ril "Matlab" /usr/share/applications/

The output was:

/usr/share/applications/matlab.desktop

being the file I generated manually. However, when I ran the command in the other directory

grep -Ril "Matlab" ~/.local/share/applications/

The output was:

/home/ongun/.local/share/applications/com-mathworks-util-postvminit.desktop
/home/ongun/.local/share/applications/mimeapps.list

After checking the first entry (since it was a .desktop file) I found that it was the culprit and deleting it remedied the duplicate icon in Dash.

The above solution, in blockquote is taken from here, this worked for me

In Matlab2017b the line the needed to be added to the .desktop file was

StartupWMClass=sun-awt-X11-XFramePeer

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like