------------------------------------------------------------------------------- Basic Mime types... Basic Desktop Mime Handling .../info/misc/mime.txt Mail mime attachments .../info/mail/mail_attachements.txt Desktop Application files .../info/misc/desktop.txt Gnome Applications .../info/X/Gnome.hints Basic information https://wiki.archlinux.org/index.php/default_applications https://specifications.freedesktop.org/mime-apps-spec/mime-apps-spec-1.0.html text/* text base data image/* image data video/* video data audio/* audio data application/* binary application data x-content/* Disk/Storage Data multipart/* messages (mail) with multiple mime parts message/* message protocols model/* 3D Model data (EG: vrml) chemical/* Chemical Information text/plain Plain undefined text application/octet-stream Binary data (save only) Description of mime type grep -e 'mime-type type=' -e '' \ /usr/share/mime/packages/freedesktop.org.xml ------------------------------------------------------------------------------- Mime Types and Desktop Applications Mime type of a file... xdg-mime query filetype "file" file -bi "file" Default application for a mimetype xdg-mime query default image/png WARNING: xdg-open does not understand multiple applications on one line! Also it returns nothing if no default is set, not even the first of the 'Added Applications'. This is why "xdg-open" is NOT recommended. Better to use... gio mime image/jpeg This returns the default (even if multiple applications are listed) A list of the registered applications, and recommended applications. I do not know how Recommended is different to Registered, they seem the same. This is what is used by "gvfs-open", which seems the better launcher. This list may not contain applications defined by ".desktop" files in ~/.local/share/applications until you run update-desktop-database ~/.local/share/applications Set default application... gio mime "image/jpeg" "xv_dir.desktop" This stores the setting into this file... ~/.config/mimeapps.list Note that this file can also specify alternative names if selected application the promary application is missing. ------------------------------------------------------------------------------- Search Order of mime to application lists... NOTE: $desktop denotes desktop environment or window manager For example: desktop=gnome # *** User defaults *** ~/.config/${desktop}-mimeapps.list ~/.config/mimeapps.list # Vendor Override (Not normally used) /etc/xdg/${desktop}-mimeapps.list /etc/xdg/mimeapps.list # Old Depreciated Compatabilty Files ~/.local/share/applications/${desktop}-mimeapps.list ~/.local/share/applications/mimeapps.list # Distribtution Provided Defaults /usr/local/share/applications/${desktop}-mimeapps.list /usr/share/applications/${desktop}-mimeapps.list /usr/local/share/applications/mimeapps.list /usr/share/applications/mimeapps.list Files contain up to 3 sections... Though '${desktop}' files can only contain 'Default Applications' Comments can be used, but are removed by "gio mime" [Default Applications] # The Applications that is to be launched by default image/gif=gthumb.desktop image/jpg=feh.desktop;shotwell-viewer.desktop;eog.desktop; video/*=vlc.desktop [Added Associations] # Other associations for use in File Manager Menus (extra to .desktop files) image/png=xv_dir.desktop;gthumb.desktop; audio/x-mp3=easytag.desktop;audacious.desktop; [Removed Associations] # Blacklist an association, # Application should never launch for these mime type # the entries should also not appear in 'Added' text/html=firefox.desktop; WARNING: Changes to the ".desktop" files MUST be updated to XML cache databases using "update-desktop-database" to create a "mimeinfo.cache" file. Otherwise you will need to manually update the "mimeapps.list" files 'Added Associations' lists. update-desktop-database ~/.local/share/applications Do this for changes in system directories too Which updates files such as... /usr/share/applications/mimeinfo.cache ~/.local/share/applications/mimeinfo.cache ------------------------------------------------------------------------------- File Suffix to mimeinfo The "/etc/mime.types" file associates filename extensions with mime types For example text/plain txt text/html htm html Look for "mime.types" all over the system especially in /etc /usr/etc /etc/htdig \ /etc/cups /usr/share/cups/mime \ /usr/share/doc/lynx-*/samples /opt/exmh-*/lib \ $HOME/apps/exmh-*/lib See my script "mailfile" for x in /etc /usr/etc `locate -r /mime\.types\$` do [ ! -r "$x/mime.types" ] && continue mimetypes="$mimetypes $x/mime.types" done [ -f $HOME/lib/mime.types ] && mimetypes="$HOME/lib/mime.types $mimetypes" Search them ALL, accepting the first match # Read the mime type basied on file suffix... suffix=`expr "$file" : '.*\.\([^./]*\)$'` if [ "$suffix" ]; then s=`printf '[ \t]'` # space and tab regular expression type=`sed -n "s/\$/ /; /$s$suffix$s/ { s/$s.*//; p; q; }" $mimetypes` fi -- Shared MIME information database Also mimetypes are stored in multiply XML files in /usr/share/mime/ For example see /usr/share/mime/audio/mp4.xml New types are added to "packages" and these are merged with the above specific 'type' files to generate the lookup files. Also note these files generated from the XML files using the "update-mime-database" command /usr/share/mime/globs /usr/share/mime/globs2 mapping suffixes (file globs) to mime types /usr/share/mime/subclasses mapping a mimetype to 'simpler' mimetype text/html -> text/plain /usr/share/mime/aliases mapping mimetypes to more offical types video/x-avi -> video/x-msvideo which maps to the XML file /usr/share/mime/video/x-msvideo.xml /usr/share/mime/generic-icons mime type to desktop icons (for themes in file managers) You can add personal mime modifications to ~/.local/share/mime Then update using... update-mime-database ~/.local/share/mime See also http://freedesktop.org/wiki/Specifications/shared-mime-info-spec/ -- Other mime related files... /usr/share/misc/magic magic used by "file" ("~/.magic" can override) -------------------------------------------------------------------------------