How do I make a Matlab launcher for Unity?

Garrett's answer almost works for me, but instead I have to use

StartupWMClass=sun-awt-X11-XFramePeer

This still gives an extra launcher icon while the splashscreen is visible (because the WM_CLASS of the spashscreen is just "MATLAB"), but then the window gets properly grouped under the launcher.

New instances of Matlab (started by terminal, or Synapse, or from another tty with export DISPLAY=:0) also get grouped under this launcher, and the launcher's quit option kills all of them.

I found this WM_CLASS value by using

$ xprop WM_CLASS

and then clicking on the Matlab window, a command I got from Superuser.

To prevent the temporary extra launcher icon, you can also add the -nosplash flag after the -desktop one.

So, my ~/.local/share/applications/MATLAB.desktop looks like this:

[Desktop Entry]
Version=1.0
Type=Application
Icon=matlab
Name=Matlab
Comment=Start MATLAB - The Language of Technical Computing
Exec=matlab -desktop -nosplash
Terminal=false
Categories=Development;
StartupNotify=true
StartupWMClass=sun-awt-X11-XFramePeer
X-Ayatana-Desktop-Shortcuts=New_Window;

Name[en_US]=MATLAB

[New_Window Shortcut Group]
Name=start a new MATLAB instance
Exec=matlab -desktop

This is on Ubuntu 12.10, with Matlab R2012b


That's very odd. matlab -desktop really ought to do the trick.

Approach 1: see what's wrong with the launcher

I have a working MATLAB icon in my Unity sidebar. I can click it, it maintains the correct icon and doesn't open a terminal. As far as I can see it is pretty much the same as your code, though:

[Desktop Entry]
Version=1.0
Type=Application
Terminal=false
Exec=/usr/local/MATLAB/R2011b/bin/matlab -desktop
Name=MATLAB
Icon=/home/tomas/icons/Matlab_Logo.png

The above code is in matlab.desktop, which is placed in /usr/share/applications/. The only differences I see that could matter are (i) the Exec path, but if you installed symlinks during your MATLAB installations yours should work just fine and (ii) I'm running MATLAB R2011b.

Like you, I'm running Ubuntu 12.04.

In case I missed something, you could try to use my code to start MATLAB, who knows, it might work.

Approach 2: a dirty workaround with the terminal

You mentioned entering matlab -desktop in the terminal works (i.e. adding Terminal=true). However, that gives you two screens grouped under the MATLAB.

You could try to fix this by changing how you call the process. The key here would be the ampersand & symbol. What that does is execute the preceding code, not waiting for it to finish. Ideally, it would start the terminal, let the terminal start MATLAB and immediate close the terminal, leaving MATLAB running. What happens if you start matlab from the terminal with the ampersand after the line, or:

matlab -desktop &

If that works, you could try (i) making a launcher with Terminal=true and the above code or (ii) making a launcher that refers to a bash script, which in turn calls the above code.

For you, Approach 1 didn't help. If Approach 2 doesn't work either it might be good to play around a bit, see what you can and cannot do with the ampersand, terminal and bash scripts. I'm pretty much out of good ideas, but someone smarter than me might be able to help you out then.


I installed a Matlab Configuration file/script from the Software Center. It lists the Matlab launcher in the dash and works perfectly for Matlab2011a in Ubuntu 12.04. But it is not working from the launcher. I mean, if you lock it on the launcher and try to start it from there then it won't work, at least it is not working for me. So I have to start it from the dash.

To install this, go to the Ubuntu Software Center, search for the Matlab, it should be the first one on the list (the icon is a Matlab logo). Just install it, and it will take care the rest.