XDG-MIME(1) | xdg-mime Manual | XDG-MIME(1) |
xdg-mime - command line tool for querying information about file type handling and adding descriptions for new file types
xdg-mime query {filetype FILE | default mimetype}
xdg-mime default application mimetype(s)
xdg-mime install [--mode mode] [--novendor] mimetypes-file
xdg-mime uninstall [--mode mode] mimetypes-file
xdg-mime {--help | --manual | --version}
The xdg-mime program can be used to query information about file types and to add descriptions for new file types.
query file
Please note that FILE names starting with a - will be rejected, this can be mitigated:
The query file option is for use inside a desktop session only. It is not recommended to use xdg-mime query file as root.
query default
The value returned by this command may or may not match the application launched by xdg-open as xdg-open hands over to desktop specific openers most of the time which may implement their own logic.
The query default option is for use inside a desktop session only. It is not recommended to use xdg-mime query default as root.
default
application is the desktop file id of the application and has the form vendor-name.desktop. application must already be installed in the desktop menu before it can be made the default handler. The application'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.
Security Note: Never set a handler that will blindly execute code or commands from the file being handled. Such behaviour will sooner than later lead to unintended code execution i.e. through a curious user trying to inspect a freshly downloaded file but running it by accident.
Keeping opening and executing separate actions helps with people protecting themselves from malware, the default handler is an opener, not a runner.
The default option is for use inside a desktop session only. It is not recommended to use xdg-mime default as root.
install
uninstall
--mode mode
The default is to use system mode when called by root and to use user mode when called by a non-root user.
--novendor
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.
--help
--manual
--version
xdg-mime honours the following environment variables:
XDG_UTILS_DEBUG_LEVEL
XDG_UTILS_INSTALL_MODE
An exit code of 0 indicates success while a non-zero exit code indicates failure. The following failure codes can be returned:
1
2
3
4
5
xdg-icon-resource(1), xdg-desktop-menu(1), Shared MIME database specification[1], MIME applications associations specification[2]
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 follows.
shinythings-shiny.xml: <?xml version="1.0"?> <mime-info xmlns='http://www.freedesktop.org/standards/shared-mime-info'>
<mime-type type="text/x-shiny">
<comment>Shiny new file type</comment>
<glob pattern="*.shiny"/>
<glob pattern="*.shi"/>
</mime-type> </mime-info>
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
Copyright © 2006
05/16/2024 | xdg-utils 1.0 |