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?

  • How are you trying to open the file? Under most unices, this is a per-application concept, not a generic OS concept. – Gilles 'SO- stop being evil' Dec 21 '10 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 '10 at 1:17
  • Chromium and xdg-open both use the FreeDesktop database. I don't know about pcmanfm. – Gilles 'SO- stop being evil' Dec 22 '10 at 18:53
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.

  • That's the FreeDesktop MIME database. Other applications might use the system database (/etc/mailcap, ~/.mailcap); Firefox has its own proprietary database. – Gilles 'SO- stop being evil' Dec 22 '10 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. – Maciej Piechotka Dec 22 '10 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 '11 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.

  • To determined the mime type for xdg-mime you should probably use: xdg-mime query filetype <file> – A.Danischewski Oct 13 at 16:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.