conquer your file associations in kde!

November 4th, 2008

So everyone knows KDE is a mammoth. And that it's very configurable. The problem is when you have to configure something for which there isn't a gui. For all I know, KDE's system of config files is completely sane and reasonable, but as a user I've never known how to understand it or where to read the explanation.

One thing that has always annoyed me across operating systems is mime types/file associations. You need some kind of mapping between file types and associated applications, and it always ends up being a kind of registry that's a pain to maintain. KDE is like that too.

Here's what I've found out. The application entries that appear in that gui are defined in .desktop files that live in /usr/share/applications. So to get your app in there, you clone an existing .desktop file and edit. In my case, I like to play all video media in mplayer, the non-gui version. Because it's non-gui, it's usually not set up through the package. Instead gmplayer, which I don't want, is. So I've made my own mplayer-nogui.desktop file.

[syntax,mplayer-nogui.desktop,bash]

Now, to make your app appear under the file types you want, you just put this in the .desktop file. Once you've done that, you have a reusable mplayer-nogui.desktop that you can push into /usr/share/applications on any distro that fails to set up mplayer without a gui.

The next step is to make MPlayer nogui the preferred app for every file type that it's associated with. This is stored in ~/.kde/share/config/profilerc. The file is easy to figure out, and ideally I'd want an easy way to just select all and then override with MPlayer nogui. But to do that I'd have to write a parser, and it's frankly not worth the effort. So I just go through the list of video filetypes and manually move MPlayer nogui to the top. It would be nice to automate this.

In terms of maintenance, linux is not the jungle that Windows is, which means apps you install later won't generally try to steal the preferred status. But they might. So again, it would be nice to automate reseting that (or maybe locking down the preferences somehow).

It would be nice if the KDE guys came out with a gui that made it possible to set up your file associations in 30 seconds, but until then this is the best I got.

:: random entries in this category ::

2 Responses to "conquer your file associations in kde!"

  1. Milan says:

    It is better to put .desktop files in ~/.local/share/applications , not in global /usr/share/applications, you don't leave cruft all over your system and no app can overwrite it.

  2. numerodix says:

    Hey, that's a good point. Thanks!