How can I add an application to the list of Open With applications?
I installed Komodo Edit from a download (wasn't available in Software Center.) I want to be able to open .php files in Komodo, but when I right-click and choose Open With Other Application, Komodo doesn't display anywhere in the list. How can I add it to the list?
Solution 1:
If you have /usr/share/applications/$application.desktop
, change
Exec=$command
to
Exec=$command %F
in the file, where $application
is the name of application, and $command
is the command to execute for desired action.
Then, you will be able to add the application to the list.
It may be necessary to change MimeType=applications/php
etc., if it is not still displayed. (Run sudo update-desktop-database
after changing that.) Although it may be needlessness for Komodo, it could be necessary for other applications.
You may use the sed
program to do the replacement. Please arrange the portion of Exec=command
according to your application.desktop
file.
sudo sed -i 's/Exec=command/Exec=command %F/' application.desktop
Solution 2:
You could simply append a blank space and %F
to the Exec
parameter in the application.desktop file of your installed application.
You mentioned you didn't install from the software center so add a "komodo.desktop" file in /usr/share/applications/
1 or ~/.local/share/applications/
2, which would be very similar to the one I'm showing, just change the Name
, Exec
, Icon
(etc) values to reflect your custom installation of komodo on your PC
Like so:
(using sublime as example because I don't use komodo)
Explanation: the %F option activates the ability of passing arguments to your application, so if ubuntu can pass an argument it will activate the "opening file with" option on the context menus, and will pass the file as an argument3. Boom, that's all there is too it, not complicated at all.
Notes:
1: You will need root privileges to modify anything on this directory. (you could use sudo nano app.desktop
from the "terminal" or open gedit with root privileges entering gksu gedit &
, it will ask for your password of course)
2: ~
stands for your user home directory (which really resides in /home/username/blabla...), and that the /.local/
directory is usually hidden, if you are using nautilus to "explore" your file system you can hit ctrl+h to show hidden files.
3: If your application doesn't support passing arguments it wont work.