May 16, 2013

setting xdg-mime defaults

Often in Linux a mime-type has the wrong application associated with it. Here i will share a short script I found hiding online (thanks to "aleb") that will assist in both finding your options and setting your defaults.

Please read http://budts.be/weblog/2011/07/xdf-open-vs-exo-open first.

If you've read the link you understand xdg-open should work on any Desktop Environment. You may however wish to alter this article for your specific D.E.

First is a script that will display every app option for every mime-type on your system.
#!/bin/sh
for dd in /usr/share/applications ~/.local/share/applications; do
 for d in $(ls $dd 2>/dev/null | grep "\\.desktop$" 2>/dev/null); do
  for m in $(grep MimeType $dd/$d | cut -d= -f2 | tr ";" " "); do
   echo xdg-mime default $d $m;
  done;
 done;
done;

To use this copy paste into a file named mimetypes.sh, then make it executable with chmod +x mimetypes.sh

Now run it: ./mimetypes.sh

You will of course see all options.

Suppose you only want to see video mime-types. Try: ./mimetypes | grep video

(Just ignore any output that begins with "grep:", the usefull ones are only the ones that begin with "xdg-mime".)

Now suppose you have vlc installed and it is the only video player you want as a default. Highlight all the lines that contain vlc (the whole code block) from your results and paste them into the bash prompt. Voila, vlc is now your default player for all video mime-types.

Suppose you have firefox and you like it best. But for whatever reason chromium is still the default when launching links or html files.

Try: ./mimetypes.sh | grep html | grep firefox

you should see something like:
xdg-mime default firefox.desktop text/html
xdg-mime default firefox.desktop application/xhtml+xml


Copy those two lines and paste into your bash shell. Now Firefox should be your default.

--------
Please consider crypto tipping:
  

No comments:

Post a Comment

Comments, Suggestions or "Thank you's" Invited! If you have used this info in any way, please comment below and link/link-back to your project (if applicable). Please Share.
I accept Bitcoin tips of ANY amount to: 1GS3XWJCTWU7fnM4vfzerrVAxmnMFnhysL
I accept Litecoin tips of ANY amount to: LTBvVxRdv2Lz9T41UzqNrAVVNw4wz3kKYk