Setting unlisted application as a default

Identify the MIME type of the file you want to open by default with one of the following commands:

xdg-mime query filetype /etc/profile

Change the default application for the specified MIME type:

xdg-mime default org.gnome.gedit.desktop text/plain

You can use autocomplete to find out the exact application name.


In addition, it is possible to add custom MIME types like this:

tee custom-mime.xml << "EOF" > /dev/null
<?xml version="1.0" encoding="utf-8"?>
<mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info">
<mime-type type="application/x-batchscript">
<comment>Batch script</comment>
<generic-icon name="text-x-script"/>
<sub-class-of type="application/x-shellscript"/>
<sub-class-of type="text/plain"/>
<glob pattern="*.bat"/>
</mime-type>
</mime-info>
EOF
sudo xdg-mime install --mode system custom-mime.xml
2 Likes