0

How can I add things the the right click menu when opening files I want to add Python to the list and make it the default but it does not even appear on the list. If posable can it please be a terminal solution. I am using raspbian with the ui mods (it had the same problem with out ui mods).

1 Answer 1

0

Assuming you're using PCManFM as your file manager, you can add apps to the right-click options for a file type by editing ~/.local/share/applications/mimeapps.list.1

mimeapps.list allows you to:

  • add even more “right-click” options to PCManFM right click menu
  • set the default program for a mimetype (exactly like in defaults.list)

You can either add an application under the [Default Applications] section, which will make it appear for all file types, or you can associate the application with a specific file type under the [Added Associations] section of mimeapps.list.

Look at your mimeapps.list

Run less ~/.local/share/applications/mimeapps.list and you will notice that each mime type under [Added Associations] appears as mime/type=desktop-id.desktop; in mimeapps.list.2

Find the mime/type you wish to associate a new app with

To find the mime and type you need to use for the particular file you wish to associate the app with, take a look at /usr/share/mime/globs2.3

For example, say you want to create a new association for python files whose name end with .py.
grep python /usr/share/mime/globs2 gives the output:

50:text/x-python:*.py
50:text/x-python:*.wsgi
50:application/x-python-bytecode:*.pyc
50:application/x-python-bytecode:*.pyo

You can see that *.py files use the mime/type of text/x-python so that is what you would add to your mimeapps.list file when associating it with an applications .desktop file.

Finding the .desktop file for the app you are associating

If you are unsure of the name of the .desktop file that represents the app you wish to associate, you should be able to find them in your /usr/share/applications/ directory. This is likely the first directory you will want to check. Alternatively, you may user specific .desktop files within the ~/.local/share/applications/ for your user.

Edit your mimeapps.list

If you want to associate *.py file with the gedit text editor, you would add the following line under the [Added Associations] section of ~/.local/share/applications/mimeapps.list:

text/x-python=gedit.desktop;

If gedit did not previously appear under the "Open With..." options for *.py files, it should now appear upon saving the update to your mimeapps.list configuration. These changes seem to take affect immediately.

You can now associate any applications in your /usr/share/applications/ directory with any mime/type in your /usr/share/mime/globs2 list.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .