donderdag 6 september 2012

File type associations with xdg-open and xdg-mime (for openbox) example

Just so I don't forget, here is how to do it - it's very simple, really:

xdg-mime default xarchiver.desktop application/x-compressed-tar

Why ?

When I clicked on a .tar.gz file in chromium, my desktop environment would hang.

This was caused the fact that chromium calls xdg-open to know which program to use to open the .tar.gz file. xdg-open used "xdg-mime query default application/x-compressed-tar" to figure out what application to use (which was none, because I hadn't configured any default application).

After that, xdg-open doesn't stop. If /etc/debian-version exists, it additionally uses run-mailcap to figure out which program to use. And mailcap was configured to run "less" somewhere down the line, which stops and apparently, stops it's parent processes for some unknown reason when run in this configuration.

So I deleted /etc/debian-version because I don't see the point of having it. We'll see if something what breaks.

How ?

xdg-mime will create the file ~/.local/share/applications/mimeapps.list which then contains:

[Default Applications]