The xdg-mime program can be used to query information about file types and to add descriptions for new file types.
Returns information related to file types.
option is for use inside a desktop session only. It is not recommended to use xdg-mime query as root.
The following queries are supported:
FILE: Returns the file type of
in the form of a MIME type.
mimetype: Returns the default application that the desktop environment uses for opening files of type
mimetype. The default application is identified by its *.desktop file.
Ask the desktop environment to make
the default application for opening files of type
mimetype. An application can be made the default for several file types by specifying multiple mimetypes.
is the desktop file id of the application and has the form vendor-name.desktop
must already be installed in the desktop menu before it can be made the default handler. The aplication's desktop file must list support for all the MIME types that it wishes to be the default handler for.
Requests to make an application a default handler may be subject to system policy or approval by the end-user. xdg-mime query can be used to verify whether an application is the actual default handler for a specific file type.
option is for use inside a desktop session only. It is not recommended to use xdg-mime default as root.
Adds the file type descriptions provided in
to the desktop environment.
must be a XML file that follows the freedesktop.org Shared MIME-info Database specification and that has a mime-info element as its document root. For each new file type one or more icons with name
must be installed with the
command in the
context. For example the application/vnd.oasis.opendocument.text filetype requires an icon by the name of application-vnd.oasis.opendocument.text to be installed.
Removes the file type descriptions provided in
and previously added with
from the desktop environment.
must be a XML file that follows the freedesktop.org Shared MIME-info Database specification and that has a mime-info element as its document root.
- --mode mode
system. In user mode the file is (un)installed for the current user only. In system mode the file is (un)installed for all users on the system. Usually only root is allowed to install in system mode.
The default is to use system mode when called by root and to use user mode when called by a non-root user.
Normally, xdg-mime checks to ensure that the
to be installed has a proper vendor prefix. This option can be used to disable that check.
A vendor prefix consists of alpha characters ([a-zA-Z]) and is terminated with a dash ("-"). Companies and organizations are encouraged to use a word or phrase, preferably the organizations name, for which they hold a trademark as their vendor prefix. The purpose of the vendor prefix is to prevent name conflicts.
Show command synopsis.
Show this manualpage.
Show the xdg-utils version information.
xdg-mime honours the following environment variables:
Setting this environment variable to a non-zero numerical value makes xdg-mime do more verbose reporting on stderr. Setting a higher value increases the verbosity.
This environment variable can be used by the user or administrator to override the installation mode. Valid values are
An exit code of 0 indicates success while a non-zero exit code indicates failure. The following failure codes can be returned:
Error in command line syntax.
One of the files passed on the command line did not exist.
A required tool could not be found.
The action failed.
No permission to read one of the files passed on the command line.
xdg-mime query filetype /tmp/foobar.png
Prints the MIME type of the file /tmp/foobar.png, in this case image/png
xdg-mime query default image/png
Prints the .desktop filename of the application which is registered to open PNG files.
xdg-mime install shinythings-shiny.xml
Adds a file type description for "shiny"-files. "shinythings-" is used as the vendor prefix. The file type description could look as folows.
<comment>Shiny new file type</comment>
An icon for this new file type must also be installed, for example with:
xdg-icon-resource install --context mimetypes --size 64 shiny-file-icon.png text-x-shiny
Kevin Krammer, Jeremy White.
- ENVIRONMENT VARIABLES
- EXIT CODES
- SEE ALSO
This document was created by
using the manual pages.
Time: 03:41:18 GMT, September 24, 2010