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'?
Asked
Active
Viewed 1.9k times
2 Answers
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
-
1I 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
-
1This 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: could you try using
/bin/sh
instead ofsh
? 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