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.


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]
Exec=matlab -desktop
Comment=Scientific computing environment

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.

| improve this answer | |
  • Have you tried 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 2 '18 at 17:53
  • Oh that's cool, I hadn't seen mimeopen before. That also worked when I did matlab -r "edit %f" (using just /<path-to-the-executable>/matlab without the edit %f part opened matlab but didn't open the file for editing) – Scott Staniewicz Apr 2 '18 at 22:19
  • 1
    Sorry for the delayed response (It's been almost a year. Between work and school I just forgot about this). Yes! Adding -r "edit %f" did exactly what I was looking for! Thank you so much for your help! In case any newbies come along and wonder where to make these changes, open terminal and paste, "sudo gedit /usr/share/applications/matlab.desktop". This will open the doc that needs to be edited. You can also edit other .desktop files for other apps by replacing matlab with the app that you're looking to edit. – Brian.H Jul 29 '18 at 14:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.