5

On my Gentoo box running without a desktop environment, every time I try to open a file the system tries to open it with Firefox. I understand that without a desktop environment "open file" cannot function correctly, but why is everything opened with Firefox? If I want to, can I change it to something else?

3
  • How are you trying to open the file? Under most unices, this is a per-application concept, not a generic OS concept. Dec 21, 2010 at 20:31
  • @Gilles I tried in various ways: double-clicking from pcmanfm, clicking from the downloaded section of chromium, executing xdg-open. Firefox always comes up.
    – phunehehe
    Dec 22, 2010 at 1:17
  • Chromium and xdg-open both use the FreeDesktop database. I don't know about pcmanfm. Dec 22, 2010 at 18:53

2 Answers 2

5

Usually this information is handled in 2 places:

  • Application .desktop files advertise what program can open
  • MIME database which specifies what application should be used to open file with specific MIME

The MIME database can be customized by editing .local/share/applications/mimeapps.list and .local/share/applications/mimeinfo.cache. The tool which allows to edit it is xdg-mime from x11-misc/xdg-utils. Please beware that man states it can be used only from inside desktop session.

Edit Please note that some applications, like Firefox, do not respect the MIME database settings.

3
  • That's the FreeDesktop MIME database. Other applications might use the system database (/etc/mailcap, ~/.mailcap); Firefox has its own proprietary database. Dec 22, 2010 at 18:54
  • I know it under name of MIME database (sounds completely different then FreeDesktop MIME database). As Freedesktop is set of standards for X desktop environments I don't think I was wrong to present is as standard - and I did mentioned not all apps respect it. Dec 22, 2010 at 19:00
  • Thanks for the right direction. The default application list is at .local/share/applications/defaults.list (which is also what xdg-mime edits).
    – phunehehe
    Feb 15, 2011 at 15:35
0

The command file -i <filename> might be useful for the cases when one does not know the specific mime type of a particular file. Once established it may be used as an input to xdg-mime utility to set the default open command.

dev-perl/File-MimeInfo ebuild constains mimeopen utility. It is a wrapper around the mentioned above commands.

1
  • To determined the mime type for xdg-mime you should probably use: xdg-mime query filetype <file>
    – Adam D.
    Oct 13, 2019 at 16:53

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .