You are here

Which Application?

Which application manages this type of file? How can I, by default, open files of type X with application Y? These questions float around in GNOME forums and mailing lists on a regular basis.

The answer is: gvfs-mime .

To determine what application by default opens a file of a given type, as well as what other applications are installed which register support for that file-type, use the --query option, like:

awilliam@GNOMERULEZ:~> gvfs-mime --query text/x-python
Default application for 'text/x-python': org.gnome.gedit.desktop
Registered applications:
    geany.desktop
    org.gnome.gedit.desktop
    calc.desktop
    ghex.desktop
    wine-extension-txt.desktop
    monodevelop.desktop
    writer.desktop
Recommended applications:
    geany.desktop
    org.gnome.gedit.desktop

Applications register support for document types using the XDG ".desktop" standard, and the default application is stored per-user in the file $XDG_DATA_HOME/applications/mimeapps.list. In most cases $XDG_DATA_HOME is $HOME/.local/share [this is the value, according to the spec, when the XDG_DATA_HOME environment variable is not set].

Not only can gvfs-mime query the association database it can be used, by the user, to set their default handler - simpler than attempting to discover the right object to right-click.

awilliam@@GNOMERULEZ:~> gvfs-mime --set text/x-python geany.desktop
Set geany.desktop as the default for text/x-python
awilliam@@GNOMERULEZ:~> gvfs-mime --query text/x-python
Default application for 'text/x-python': geany.desktop
Registered applications:
    geany.desktop
    org.gnome.gedit.desktop
    calc.desktop
    ghex.desktop
    wine-extension-txt.desktop
    monodevelop.desktop
    writer.desktop
Recommended applications:
    geany.desktop
    org.gnome.gedit.desktop

Python files are now, by default, handled by Geany.

Theme by Danetsoft and Danang Probo Sayekti inspired by Maksimer