I'm pretty new to Ubuntu so please forgive my ignorance. I've successfully installed Sublime Text 3, Matlab, Arduino IDE, Spider, and Eagle Autodesk. If I open the application and open a file then everything loads just fine. But if I go into Files, locate the desired file (like a HelloWorld.py), and right click "Open with" I am unable to select Sublime Text (or Spider). My only options are gedit and LibreOffice. Selecting "Other Application..." and "View All Applications" still doesn't allow me to select Sublime Text or Spider (they don't appear at all). I have the same issue with .m Matlab files, etc.. How can I get these applications as available options? I'm not sure where these applications are located. I used 'type matlab' to locate Matlab but I haven't been able to use that method to locate any other applications. I'd greatly appreciate help with this issue.
1 Answers
I had this problem and found the answer here: https://ubuntugenius.wordpress.com/2012/06/18/ubuntu-fix-add-program-to-list-of-applications-in-open-with-when-right-clicking-files-in-nautilus/ and http://www.walkingrandomly.com/?p=300 .
Summary: There should be a matlab.desktop file which tells Ubuntu how to handle opening the application. It should be in either /usr/share/applications
or ~/.local/share/applications
.
The fix is to add -r "edit %f"
to the end of the "Exec" line in that file.
Mine looked like this
$ cat /usr/share/applications/matlab.desktop
[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
I just changed that file only in the Exec line to say
Exec=matlab -desktop -r "edit %f"
and it immediately appeared in the "Open With" menu.
For some reason, unlike other applications where you can just add "%f" to the end of the Exec line, MATLAB doesn't actually open that file to edit without specifically saying "run the command edit %f
", which then edits the file you are right clicking to open.
https://ubuntuforums.org/showthread.php?t=794255 This explains with the extra %f
means, as does What does “%U” mean when calling a command? this answer.
It basically just tells matlab
to pass whatever you are right clicking to open as an argument to the matlab
command.

- 121
mimeopen -d file.<type>
->Other
->/<path-to-the-executable>/matlab
. References: How do I set the default file association? and Where can I find the location of folders for installed programs? – pa4080 Apr 02 '18 at 17:53mimeopen
before. That also worked when I didmatlab -r "edit %f"
(using just/<path-to-the-executable>/matlab
without theedit %f
part opened matlab but didn't open the file for editing) – Scott Staniewicz Apr 02 '18 at 22:19