No. 49 Vol. 1Fri 06 August 2021Price: 0/0d

xdg-mime, a short guide

pointing finger How Did I Do >> Fri 06 August 2021 by Thran

On Linux, xdg-open and xdg-mime configure the default applications for opening file types. A situation has forced me to learn their use.


I installed a mp3 tag editor. Somehow, it was assigned the default application to open files and folders on Void Linux. This meant when I clicked 'Open Containing Folder' in Firefox it opened every file in the mp3 tag editor. Obviously not ideal.

Fixing it was as follows:

First, I needed to confirm what was set as the default program to open directories.

$ xdg-mime query default inode/directory

Revealed that this was truly the culprit. So switching it back to my file manager (pcmanfm) was as follows:

$ xdg-mime default pcmanfm.desktop inode/directory

And the next time I went to Open the Containing Folder in Firefox, it worked!

List .applications for xdg-mime & xdg-open

If you want to check which applications are available to configure with xdg, look here:

$ ls /usr/share/applications/

You should see plenty of files ending in .application. Any one of these may be assigned as a default application in a manner like that noted above.

Find the mime-type for a file:

Run this:

$ xdg-mime query filetype

Then use the result, e.g. text/plain, in your assignment of a xdg-mime default to an application.


This is equivalent to open on OSX. Simply run ./xdg-open <filename> and this will open the file in the default program, as assigned by xdg. I use this often when editing HTML in VIM and I quickly want to open the file in Firefox to see it visually.


Tags for this writ:

linux, desktop, void linux,

Latest in How Did I Do

If that wasn't enough, see all in How Did I Do (4 total). Back to writ top.