You are not logged in.

#1 2018-05-26 10:51:43

tillyboy
Member
Registered: 2018-05-26
Posts: 1

Registering an application and MIME type (overwrite existing globs)

Hello everyone,

I consistently fail at registering a new MIME type and the corresponding application correctly. Let me start of with my registration script:

append() {
  echo $2 | sudo tee --append $1
}

# ------------------------------- add mime type -------------------------------- #
sudo xdg-mime install --mode system assets/mime-data/application/x-pdb.xml
sudo xdg-icon-resource install --mode system --context mimetypes --size 512 assets/mime-data/application/pdb.png application-x-pdb
xdg-mime default pymol.desktop application/x-pdb

# ------------------------------- desktop fixes -------------------------------- #
# remove deprecated encoding config
sudo sed -i 's/Encoding=UTF-8//' /usr/share/applications/pymol.desktop
# %F flag allows to open files
sudo sed -i 's/Exec=pymol$/Exec=pymol %F/' /usr/share/applications/pymol.desktop
# associate with MIME type
if [[ $(grep -c MimeType /usr/share/applications/pymol.desktop) = 0 ]];then
  append /usr/share/applications/pymol.desktop 'MimeType=application/x-pdb'
fi


# remove other pdb types interfering with this
sudo sed -i 's/<glob pattern="*.pdb"/>//' /usr/share/mime/application/x-aportisdoc.xml
sudo sed -i 's/<glob pattern="*.pdb"/>//' /usr/share/mime/application/vnd.palm.xml

sudo update-desktop-database
sudo update-mime-database

Resources:
Arch Wiki
Fedora Forums

First of all I am running Gnome to use this. I do get Pymol to display on a file with context menu>Open with other application>View all applications. My goal is to associate Pymol with all .pdb files on double clicking. Alongside this I noticed a few things:

  1. Alongside /usr/share/mime/application/x-pdb.xml I get another file at /usr/share/mime/packages/x-pdb.xml. Why is that? Do I need this file? Could it cause problems?

  2. I do not get the file /usr/share/applications/mimeapps.list, neither do I get /usr/share/applications/defaults.list (which according to the wiki is deprecated anyway)

  3. I do get a bunch of lines associated with associated with either application/x-pdb or the glob pattern *.pdb in /usr/share/mime/globs:

    # This file was automatically generated by the
    # update-mime-database command. DO NOT EDIT!
    application/x-pdb:__NOGLOBS__
    ...
    application/x-aportisdoc:*.pdb
    application/vnd.palm:*.pdb
    application/x-pdb:*.pdb
    ...

    This already tells me, that simple removal of the glob patterns in the corresponding mime-type.xml did not work out.
    The corresponding entries in glob2 are:

    # This file was automatically generated by the
    # update-mime-database command. DO NOT EDIT!
    0:application/x-pdb:__NOGLOBS__
    ...
    50:application/x-aportisdoc:*.pdb
    50:application/vnd.palm:*.pdb
    50:application/x-pdb:*.pdb
    ...

    I can only guess that the numbers are priorities, but I have not found any information on this yet. I also want to avoid manual edits of such files. I hope there is an option of increasing the priority e.g. through the xml files a MIME type is registered with.

My pdb files are currently recognized as application/x-aportisdoc. How can I get this to work properly, which also includes not manually editing the glob or glob2 file (as these changes would be unrolled on the next update of the MIME database)?

Thanks in advance,
tillyboy

Last edited by tillyboy (2018-05-26 11:04:37)

Offline

Board footer

Powered by FluxBB