XDG, Filezilla and more

Wed, 12/18/2013 - 19:40 -- admin


It's been long since I wrote for the last time because real life has kept me busy enough.

I'll just write today a simple note, so that if someone happens to stump on this same problem will have a tip on how to confront it, or just in case I have to come back to check my old notes as I do from time to time. My memory is not as good as it used to be :).

Today I've been doing some cleaning and updating a bit my laptop, something that I've been neglecting for quite some time. Between some other things that I might speak about some other day I have been dealing with some troubles that have been bothering me for a long time. Something about MIME types which has been giving me some headache.

To tell the truth, since this silly XDG standard arrived, I haven't stopped quarrelling with MIME types.

I am of the kind that never uses one of the massive desktops around. I do just fine with a medium-sized window manager (right now it's openbox, but I don't feel religious about it), and a good bunch of terminals for almost every purpose you can think of. Besides that, my basic tool set is formed by seamonkey, filezilla, bluefish, gimp and tmux running on urxvt. Mi greatest problem is managing simple things like this that occupies us right now: file associations.

After a bit of research, I have put together this script which does something as simple as associating a given file (along with all the files of the same type) to a given visor/edidtor/tool. I think this is better than having to know all the mime types of just blindingly guessing them at random.

#!/bin/bash -x
#DESKTOP_FILE=$(locate "${1}".desktop)
MIME_TYPE=$(xdg-mime query filetype "${2}")
xdg-mime default $DESKTOP_FILE $MIME_TYPE

Its usage is simple enough, assuming it's named "assoc" and that it lives on your $PATH:

assoc my_file.jpg feh

I also had a front line open with filezilla. No matter how I configure it, it does what it feel like depending on the day. So I now I have set it up to always use a custom editor, never use the file associations, and I have set the custom editor to /usr/bin/xdg-open. That, in fact, means that it will use the file associations. But the real ones (well, the ones that xdg dictates) instead of the ones it was using before (I have no idea what that could be).

This means I will probably have to associate a lot of text file extensions that I need to edit daily to bluefish (mostly web stuff and source code). But hopefully that will be easy enough, and once it's set up it shouldn't bother me again. At least not until freedesktop invents a new thing, in four or five weeks.

Saludos :)