Matlab .desktop file
(This is not about creating a launcher in the dock or anything like that.)
When I navigate into a folder with some Matlab .m files, and simply do
matlab myscript.m
in the terminal, it launches Matlab with working directory set to where the file is.
This has some perks: If there is also a startup.m file in the directory - and therefore in Matlab path - Matlab will notice and run it.
I tried to replicate this functionality with a .desktop file, so I could click an .m file (recognized as objective C by Ubuntu...) with the same results as if I run it from terminal, but no luck.
Here is what I have tried:
I put text/x-objcsrc=Matlab.desktop
in /home/jakub/.local/share/applications/mimeapps.list
and created this desktop file in /home/jakub/.local/share/applications
Version=1.0
Type=Application
Terminal=false
Exec=matlab -desktop
Name=Matlab
Icon=/home/jakub/Pictures/icons/Apps-Matlab-icon.png
Categories=Development
When I click an .m file, it launches Matlab, but it is not equivalent to running it from the terminal (see above): Mainly, work dir is set to Matlab's default, instead of where the script is, and the script does not open, just plain Matlab with empty editor.
I also tried this:
Exec=matlab -desktop -r "edit %f"
which opens the file but does not set the work dir
Exec=matlab -desktop -r "cd %d"
which changes the work dir, but after Matlab is run, which means it will not run the code in startup.m (so it is not equivalent to doing matlab myscript.m
in the terminal).
Is there any way of perfectly mimicking matlab myscript.m
as run from the terminal, but in a desktop file?
.desktop matlab
add a comment |
(This is not about creating a launcher in the dock or anything like that.)
When I navigate into a folder with some Matlab .m files, and simply do
matlab myscript.m
in the terminal, it launches Matlab with working directory set to where the file is.
This has some perks: If there is also a startup.m file in the directory - and therefore in Matlab path - Matlab will notice and run it.
I tried to replicate this functionality with a .desktop file, so I could click an .m file (recognized as objective C by Ubuntu...) with the same results as if I run it from terminal, but no luck.
Here is what I have tried:
I put text/x-objcsrc=Matlab.desktop
in /home/jakub/.local/share/applications/mimeapps.list
and created this desktop file in /home/jakub/.local/share/applications
Version=1.0
Type=Application
Terminal=false
Exec=matlab -desktop
Name=Matlab
Icon=/home/jakub/Pictures/icons/Apps-Matlab-icon.png
Categories=Development
When I click an .m file, it launches Matlab, but it is not equivalent to running it from the terminal (see above): Mainly, work dir is set to Matlab's default, instead of where the script is, and the script does not open, just plain Matlab with empty editor.
I also tried this:
Exec=matlab -desktop -r "edit %f"
which opens the file but does not set the work dir
Exec=matlab -desktop -r "cd %d"
which changes the work dir, but after Matlab is run, which means it will not run the code in startup.m (so it is not equivalent to doing matlab myscript.m
in the terminal).
Is there any way of perfectly mimicking matlab myscript.m
as run from the terminal, but in a desktop file?
.desktop matlab
add a comment |
(This is not about creating a launcher in the dock or anything like that.)
When I navigate into a folder with some Matlab .m files, and simply do
matlab myscript.m
in the terminal, it launches Matlab with working directory set to where the file is.
This has some perks: If there is also a startup.m file in the directory - and therefore in Matlab path - Matlab will notice and run it.
I tried to replicate this functionality with a .desktop file, so I could click an .m file (recognized as objective C by Ubuntu...) with the same results as if I run it from terminal, but no luck.
Here is what I have tried:
I put text/x-objcsrc=Matlab.desktop
in /home/jakub/.local/share/applications/mimeapps.list
and created this desktop file in /home/jakub/.local/share/applications
Version=1.0
Type=Application
Terminal=false
Exec=matlab -desktop
Name=Matlab
Icon=/home/jakub/Pictures/icons/Apps-Matlab-icon.png
Categories=Development
When I click an .m file, it launches Matlab, but it is not equivalent to running it from the terminal (see above): Mainly, work dir is set to Matlab's default, instead of where the script is, and the script does not open, just plain Matlab with empty editor.
I also tried this:
Exec=matlab -desktop -r "edit %f"
which opens the file but does not set the work dir
Exec=matlab -desktop -r "cd %d"
which changes the work dir, but after Matlab is run, which means it will not run the code in startup.m (so it is not equivalent to doing matlab myscript.m
in the terminal).
Is there any way of perfectly mimicking matlab myscript.m
as run from the terminal, but in a desktop file?
.desktop matlab
(This is not about creating a launcher in the dock or anything like that.)
When I navigate into a folder with some Matlab .m files, and simply do
matlab myscript.m
in the terminal, it launches Matlab with working directory set to where the file is.
This has some perks: If there is also a startup.m file in the directory - and therefore in Matlab path - Matlab will notice and run it.
I tried to replicate this functionality with a .desktop file, so I could click an .m file (recognized as objective C by Ubuntu...) with the same results as if I run it from terminal, but no luck.
Here is what I have tried:
I put text/x-objcsrc=Matlab.desktop
in /home/jakub/.local/share/applications/mimeapps.list
and created this desktop file in /home/jakub/.local/share/applications
Version=1.0
Type=Application
Terminal=false
Exec=matlab -desktop
Name=Matlab
Icon=/home/jakub/Pictures/icons/Apps-Matlab-icon.png
Categories=Development
When I click an .m file, it launches Matlab, but it is not equivalent to running it from the terminal (see above): Mainly, work dir is set to Matlab's default, instead of where the script is, and the script does not open, just plain Matlab with empty editor.
I also tried this:
Exec=matlab -desktop -r "edit %f"
which opens the file but does not set the work dir
Exec=matlab -desktop -r "cd %d"
which changes the work dir, but after Matlab is run, which means it will not run the code in startup.m (so it is not equivalent to doing matlab myscript.m
in the terminal).
Is there any way of perfectly mimicking matlab myscript.m
as run from the terminal, but in a desktop file?
.desktop matlab
.desktop matlab
asked Sep 6 '16 at 15:08
jakubjakub
1262
1262
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
I had the a similar issue, when I tried to set Matlab up manually.
Eventually, I ran:sudo apt-get install matlab-support
and followed installation instructions. This just adds Matlab to the Dashboard.
The resulting matlab.desktop file reads:
[Desktop Entry]
Version=1.0
Type=Application
Terminal=false
Exec=matlab -desktop
Name=MATLAB
Icon=/usr/share/icons/hicolor/48x48/apps/matlab.png
Categories=Development;Math;Science
Comment=Scientific computing environment
StartupNotify=true
StartupWMClass=com-mathworks-util-PostVMInit
To open .m files in matlab by clicking on them I used the Ubuntu GUI to set it to open those files with the command:
matlab -desktop -r "open %U;"
This both opens the file in Matlab and sets the current working directory to where the file is located (at least with Matlab 2016b).
I hope this information helps.
add a comment |
A naive answer: have you tried
Exec=bash matlab %f
In principle, this should be equivalent to you running it on the shell with the file as argument.
Seems logical, but does not work. Neitherbash matlab %f
orbash matlab -desktop %f
seems to do anything. When providing a full path to Matlab executable (instead of justmatlab
) Matlab launches, and in htop, I can see a lot of lines saying/usr/path/to/matlab -desktop /home/path/to/myscript.m
but the result is the same - opened with the default working dir and does not open the script in the editor. So it is still not equivalent to launching it from the terminal.
– jakub
Sep 7 '16 at 9:31
Sorry I could not be of more help. I am curious on the solution as I am a frequent Matlab user and see the potential of what you are looking to accomplish.
– Juan Antonio
Sep 8 '16 at 0:38
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "89"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f821721%2fmatlab-desktop-file%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
I had the a similar issue, when I tried to set Matlab up manually.
Eventually, I ran:sudo apt-get install matlab-support
and followed installation instructions. This just adds Matlab to the Dashboard.
The resulting matlab.desktop file reads:
[Desktop Entry]
Version=1.0
Type=Application
Terminal=false
Exec=matlab -desktop
Name=MATLAB
Icon=/usr/share/icons/hicolor/48x48/apps/matlab.png
Categories=Development;Math;Science
Comment=Scientific computing environment
StartupNotify=true
StartupWMClass=com-mathworks-util-PostVMInit
To open .m files in matlab by clicking on them I used the Ubuntu GUI to set it to open those files with the command:
matlab -desktop -r "open %U;"
This both opens the file in Matlab and sets the current working directory to where the file is located (at least with Matlab 2016b).
I hope this information helps.
add a comment |
I had the a similar issue, when I tried to set Matlab up manually.
Eventually, I ran:sudo apt-get install matlab-support
and followed installation instructions. This just adds Matlab to the Dashboard.
The resulting matlab.desktop file reads:
[Desktop Entry]
Version=1.0
Type=Application
Terminal=false
Exec=matlab -desktop
Name=MATLAB
Icon=/usr/share/icons/hicolor/48x48/apps/matlab.png
Categories=Development;Math;Science
Comment=Scientific computing environment
StartupNotify=true
StartupWMClass=com-mathworks-util-PostVMInit
To open .m files in matlab by clicking on them I used the Ubuntu GUI to set it to open those files with the command:
matlab -desktop -r "open %U;"
This both opens the file in Matlab and sets the current working directory to where the file is located (at least with Matlab 2016b).
I hope this information helps.
add a comment |
I had the a similar issue, when I tried to set Matlab up manually.
Eventually, I ran:sudo apt-get install matlab-support
and followed installation instructions. This just adds Matlab to the Dashboard.
The resulting matlab.desktop file reads:
[Desktop Entry]
Version=1.0
Type=Application
Terminal=false
Exec=matlab -desktop
Name=MATLAB
Icon=/usr/share/icons/hicolor/48x48/apps/matlab.png
Categories=Development;Math;Science
Comment=Scientific computing environment
StartupNotify=true
StartupWMClass=com-mathworks-util-PostVMInit
To open .m files in matlab by clicking on them I used the Ubuntu GUI to set it to open those files with the command:
matlab -desktop -r "open %U;"
This both opens the file in Matlab and sets the current working directory to where the file is located (at least with Matlab 2016b).
I hope this information helps.
I had the a similar issue, when I tried to set Matlab up manually.
Eventually, I ran:sudo apt-get install matlab-support
and followed installation instructions. This just adds Matlab to the Dashboard.
The resulting matlab.desktop file reads:
[Desktop Entry]
Version=1.0
Type=Application
Terminal=false
Exec=matlab -desktop
Name=MATLAB
Icon=/usr/share/icons/hicolor/48x48/apps/matlab.png
Categories=Development;Math;Science
Comment=Scientific computing environment
StartupNotify=true
StartupWMClass=com-mathworks-util-PostVMInit
To open .m files in matlab by clicking on them I used the Ubuntu GUI to set it to open those files with the command:
matlab -desktop -r "open %U;"
This both opens the file in Matlab and sets the current working directory to where the file is located (at least with Matlab 2016b).
I hope this information helps.
edited 2 hours ago
Jonas Stein
127110
127110
answered Dec 26 '16 at 8:13
yaron160yaron160
181117
181117
add a comment |
add a comment |
A naive answer: have you tried
Exec=bash matlab %f
In principle, this should be equivalent to you running it on the shell with the file as argument.
Seems logical, but does not work. Neitherbash matlab %f
orbash matlab -desktop %f
seems to do anything. When providing a full path to Matlab executable (instead of justmatlab
) Matlab launches, and in htop, I can see a lot of lines saying/usr/path/to/matlab -desktop /home/path/to/myscript.m
but the result is the same - opened with the default working dir and does not open the script in the editor. So it is still not equivalent to launching it from the terminal.
– jakub
Sep 7 '16 at 9:31
Sorry I could not be of more help. I am curious on the solution as I am a frequent Matlab user and see the potential of what you are looking to accomplish.
– Juan Antonio
Sep 8 '16 at 0:38
add a comment |
A naive answer: have you tried
Exec=bash matlab %f
In principle, this should be equivalent to you running it on the shell with the file as argument.
Seems logical, but does not work. Neitherbash matlab %f
orbash matlab -desktop %f
seems to do anything. When providing a full path to Matlab executable (instead of justmatlab
) Matlab launches, and in htop, I can see a lot of lines saying/usr/path/to/matlab -desktop /home/path/to/myscript.m
but the result is the same - opened with the default working dir and does not open the script in the editor. So it is still not equivalent to launching it from the terminal.
– jakub
Sep 7 '16 at 9:31
Sorry I could not be of more help. I am curious on the solution as I am a frequent Matlab user and see the potential of what you are looking to accomplish.
– Juan Antonio
Sep 8 '16 at 0:38
add a comment |
A naive answer: have you tried
Exec=bash matlab %f
In principle, this should be equivalent to you running it on the shell with the file as argument.
A naive answer: have you tried
Exec=bash matlab %f
In principle, this should be equivalent to you running it on the shell with the file as argument.
answered Sep 6 '16 at 15:59
Juan AntonioJuan Antonio
8411526
8411526
Seems logical, but does not work. Neitherbash matlab %f
orbash matlab -desktop %f
seems to do anything. When providing a full path to Matlab executable (instead of justmatlab
) Matlab launches, and in htop, I can see a lot of lines saying/usr/path/to/matlab -desktop /home/path/to/myscript.m
but the result is the same - opened with the default working dir and does not open the script in the editor. So it is still not equivalent to launching it from the terminal.
– jakub
Sep 7 '16 at 9:31
Sorry I could not be of more help. I am curious on the solution as I am a frequent Matlab user and see the potential of what you are looking to accomplish.
– Juan Antonio
Sep 8 '16 at 0:38
add a comment |
Seems logical, but does not work. Neitherbash matlab %f
orbash matlab -desktop %f
seems to do anything. When providing a full path to Matlab executable (instead of justmatlab
) Matlab launches, and in htop, I can see a lot of lines saying/usr/path/to/matlab -desktop /home/path/to/myscript.m
but the result is the same - opened with the default working dir and does not open the script in the editor. So it is still not equivalent to launching it from the terminal.
– jakub
Sep 7 '16 at 9:31
Sorry I could not be of more help. I am curious on the solution as I am a frequent Matlab user and see the potential of what you are looking to accomplish.
– Juan Antonio
Sep 8 '16 at 0:38
Seems logical, but does not work. Neither
bash matlab %f
or bash matlab -desktop %f
seems to do anything. When providing a full path to Matlab executable (instead of just matlab
) Matlab launches, and in htop, I can see a lot of lines saying /usr/path/to/matlab -desktop /home/path/to/myscript.m
but the result is the same - opened with the default working dir and does not open the script in the editor. So it is still not equivalent to launching it from the terminal.– jakub
Sep 7 '16 at 9:31
Seems logical, but does not work. Neither
bash matlab %f
or bash matlab -desktop %f
seems to do anything. When providing a full path to Matlab executable (instead of just matlab
) Matlab launches, and in htop, I can see a lot of lines saying /usr/path/to/matlab -desktop /home/path/to/myscript.m
but the result is the same - opened with the default working dir and does not open the script in the editor. So it is still not equivalent to launching it from the terminal.– jakub
Sep 7 '16 at 9:31
Sorry I could not be of more help. I am curious on the solution as I am a frequent Matlab user and see the potential of what you are looking to accomplish.
– Juan Antonio
Sep 8 '16 at 0:38
Sorry I could not be of more help. I am curious on the solution as I am a frequent Matlab user and see the potential of what you are looking to accomplish.
– Juan Antonio
Sep 8 '16 at 0:38
add a comment |
Thanks for contributing an answer to Ask Ubuntu!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f821721%2fmatlab-desktop-file%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown