James Gardner: Home > Blog > 2007 > Gnome File and Program...

Gnome File and Program Associations in Debian

Posted:2007-07-21 12:31
Tags:Desktop Software, Debian

One niggle I've had with Gnome for a while is that when I click a link in Icedove (Debian's name for the Thunderbird mail program) it loads the page in Epiphany, the Gnome browser, instead of Iceweasel (Debian's version of Firefox). Also I use gVim as my text editor but text files load in gEdit by default.

I initially thought the "Preferred Applications" program would be the place to make the change, then I thought there might be a file associations program to handle my preferences but there didn't appear to be. The reason for my problem was that I didn't understand how Debian handles preferred applications.

Program associations are handled via the update-alternatives program which must be run as root. In Debian, programs register themselves as alternatives to perform the same actions. Debian will choose an alternative by default but if you want to change it you can use the command line program.

For example, to make Iceweasel my default browser I run this command:

james@dirac:~$ sudo update-alternatives --config x-www-browser

Here is the output:

There are 2 alternatives which provide `x-www-browser'.

  Selection    Alternative
-----------------------------------------------
*+        1    /usr/bin/epiphany
          2    /usr/bin/iceweasel

Press enter to keep the default[*], or type selection number: 2
Using `/usr/bin/iceweasel' to provide `x-www-browser'.</code>

Incidentally, the current choice is marked with a ’*’ and the choice with the highest priority with a ’+’.

System Message: WARNING/2 (<string>, line 29); backlink

Inline emphasis start-string without end-string.

Iceweasel is now the default alternative to handle any browser related actions throughout Gnome and indeed Debian. Handy eh?

Rather pleased with this I decided to change some other associations but needed to know what group name to use. You can see a list of all the alternatives with this command but you should never manually edit files in this directory. Use the update-alternatives program to do that.

ls -l /etc/alternatives/

Part of the output looks like this:

lrwxrwxrwx 1 root root  18 2007-07-21 11:57 x-www-browser -> /usr/bin/iceweasel
lrwxrwxrwx 1 root root  34 2007-07-21 11:57 x-www-browser.1.gz -> /usr/share/man /man1/iceweasel.1.gz

As you can see x-www-browser now points to /usr/bin/iceweasel but what is interesting is that the man page has also been updated as a dependency so that you don't get a man page for a different browser when trying to access the help.

Well, that's how to choose preferred applications, now for changing which applications are associated with which file types. I haven't worked out how to do this on the command line so if anyone knows I'd like to hear but you can do it via the Gnome GUI.

Right click on a text file, choose Properties then click the Open With tab. The tab presents a list of alternatives for the particular file type. Simply choose the application you prefer and click OK. Those file types will now be associated with the application you've chosen.

The Open With dialog in Gnome for choosing file associations

(view source)

James Gardner: Home > Blog > 2007 > Gnome File and Program...