Sunday, May 18, 2008

Controlling file associations in Gnome

Gnome, whether under redhat or ubuntu, is very hard to configure. Especially controlling the behaviour when you double-click on a file. However I may've got it cracked.

First, the easy way, is right-click a file, choose properties, and there is the open with tab. The setting there affects all files with that extension. (I still think that is one of those things that isn't even obvious once you know about it!)

But sometimes that is not enough. E.g. *.as files were associated with x-applix-spreadsheet, instead of my text editor. And then it then complains I'm trying to open a suspicious file.

Solution: I created this xml file as
/usr/share/mime/packages/actionscript.xml:


<?xml version="1.0" encoding="UTF-8"?>
<mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info">
<mime-type type="application/x-actionscript">
<comment>Actionscript</comment>
<glob pattern="*.as">
</mime-type>
</mime-info>

Wow, that seemed to do the job!

1 comment:

Unknown said...

In Ibex you need to close glob the tag with a /> and then run 'sudo update-mime-library /usr/share/mime' for the changes to take effect.

I picked up an actionscript language file for gedit over here: http://www.conic.se/blog/posts/8/ he has a language file for mxml also :)

Make sure the mime types match, your mime type is 'application/x-actionscript' and the language file is 'text/x-actionscript'. Once you change them to match then gedit hilights the actionscript within your mxml also :)

Cheers,
Aaron