About Me

This blog is for informational purposes. By following any advice in this blog, you are solely responsible for any and all damages. Accelerant Learning Games, LLC is not responsible for any damage to your property, finances or self occuring from following any and all advice in this blog.

Saturday, April 16, 2011

In Archlinux II: Implementing MIME and .desktop files outside of a desktop environment

One of the biggest problems Window Manager users face is the lack of an integrated freedesktop system. It is very likely that a useful, seemingly desktop-independent program uses MIME filetypes and desktop environment libraries to function, such as Firefox or Chrome. They both rely on the MIME database to do tasks from the Download Window like opening a PDF or the directory containing the downloaded file, regardless of what File Association is specified in the Preferences dialog. If you have GIMP installed, for example, even if you've specified another PDF viewer (regardless of whether or not it's MIME-based). Firefox and Chrome will both rely on GIMP to open PDFs, because it's the specified default in your mimeinfo.cache file.

Here's 3 ways on how to fix that particular problem

1). If you are comfortable with the command line, and have a $HOME/.local/share/applications/default.list present, this method will work. This requires a .desktop file associated with a pdf-viewer (but this will work for any other MIME filetype of which you know the extension).  you can simply enter:

xdg-mime  default  program.desktop  application/pdf

where program.desktop is a .desktop file residing in /usr/share/applications/. Finish this up with:

update-mime-database <mime-directory>

If you need a .desktop file for your program, follow these links:

Tutorial on .desktop creation from the FreeDesktop Project

Help on how to create a .desktop file from the Archlinux wiki

Help on how to create a .desktop file from the Gnome wiki

2). If you're not comfortable with the CLI, graphical solutions to MIME alterations also exist for this, such as MIME-Editor, MIMEo, and Perl-file-mimeinfo. These are fairly easy to use, but if used incorrectly can introduce errors into your MIME setup.

3). The edit-config-files-by-hand way: If neither of the above attempts work, or you just like doing things the hard way, this is the fallback de facto method. Depending on if you want a system-wide alteration or per-user basis alteration, try to find either file:

in either your /usr/share/applications/ or $HOME/.local/share/applications/ directories respectively. Which file you will need to edit will depend on your Linux distro.
Find the line that says:
and either comment it by prefixing a #, or changing the right-hand side how you wish. If you comment it, Firefox will fall back onto whatever your File Association is set to. If you change it to another program, be sure to have a .desktop file association ready.

Update this with update-mime-database.Sendgrid.

More info:

Archlinux Custom File Associations

How to set default MIME-associated applications system wide

Overview on the .desktop system from FreeDesktop Project

No comments:

Post a Comment