13

I want to create a quick launch icon for MATLAB, but it won't start if the working directory is not the same as the directory where the executable is. Can I specify the working directory in the 'Custom Application Launcher'?

Custom launcher

sashoalm
  • 5,131

2 Answers2

18

You can set the working directory natively, but for some reason it's not supported in the user interface. The underlying .desktop file itself supports a Path key for "the working directory to run the program in" (see the spec) as long as your launcher is an "Application" type.

So just open the .desktop file in a text editor (if you're having trouble finding it, you can create the launcher on your desktop and find it in ~/Desktop, then move it later), and add a line at the end that says Path=YOUR_PATH.

Mu Mind
  • 310
  • Amazing. I can't believe Gnome is missing this in the UI. Any idea if it's visible in latest gnome versions? – user1338062 Feb 20 '13 at 17:26
  • 1
    I don't think it's been added, and in fact I think recent versions of gnome dropped the "Create Application Launcher" option. I recommend https://github.com/MicahCarrick/desktop-entry-editor as a replacement. – Mu Mind Feb 21 '13 at 05:37
8

Change the Command to this (substituting the correct paths of course):

bash -c "cd /path/to/directory && /path/to/directory/executable"
Isaiah
  • 59,344
  • 1
    This sort of worked, but only after I set Type to 'Application in Terminal'. For some reason it doesn't work if it's just Application. – sashoalm Jun 22 '11 at 18:41
  • @satuon Strange, maybe that's a MATLAB specific thing. – Isaiah Jun 22 '11 at 19:03
  • @satuon: could you try using /bin/sh instead of sh? Perhaps it works then – Lekensteyn Jun 22 '11 at 19:27
  • @sashoalm (better late than never) you need to specify the option -desktop if you dont want to run it from terminal. http://www.mathworks.com/help/matlab/ref/matlablinux.html – aiao Apr 26 '15 at 18:20