Years later, I've made a small utility that scans MIME database (both system and user) and register all known native mime-types in Windows registry.
It uses xdg-open
to open a file if there is a default (native) application for that
mime type, otherwise uses packagekit
to search for a package that can handle
that file (just like what Nautilus does). So my initial requirement of registering only extensions that have an installed, native application was not needed anymore. However, an early version of the script did filter only such types. The snippet that made it possible was:
perl -e '
use strict; use warnings;
use File::MimeInfo::Magic; use File::MimeInfo::Applications;
while (my $line = <STDIN>) {
chomp($line);
my ($ext, $mime) = (split/\t/, $line);
my ($def, @apps) = mime_applications_all($mime);
print "$line\n" if ($def || @apps)
}'
By default my script only registers native types that have no handler in windows
registry, but it can also override such associations (so, for example, jpeg
files are opened in native viewer instead of the default Gecko wine browser).
It can also ignore some extensions even if they have no handler in windows.
It tries its best to be winemenubuilder-friendly, meaning all associations it
creates is not published as native associations (or as x-wine-extension
mimetypes) by winemenubuilder, which would be ugly and potentially cause loops.
This is very tricky and not yet perfect, specially with mixed-case extensions
(.C and .c for example)
That said, I hope this script is helful for everyone:
https://github.com/MestreLion/wine-tools/blob/master/wine-import-extensions
Improvements welcome!
Rename the file you have as _anything_.task
(where _anything_
is something suitably descriptive.)
First you need to create an XML file with the extension information in it. (If you wish, copy the text below into a new text file and save it as task.xml
.)
<?xml version="1.0" encoding="UTF-8"?>
<mime-info xmlns='http://www.freedesktop.org/standards/shared-mime-info'>
<mime-type type="application/taskcouch">
<comment>TaskCoach File</comment>
<comment xml:lang="bg">Taskcoach</comment>
<comment xml:lang="cs">Taskcoach</comment>
<comment xml:lang="de">Taskcoach</comment>
<comment xml:lang="es">Taskcoach</comment>
<comment xml:lang="eu">Taskcoach</comment>
<comment xml:lang="hu">Taskcoach</comment>
<comment xml:lang="it">Taskcoach</comment>
<comment xml:lang="ko">Taskcoach</comment>
<comment xml:lang="nb">Taskcoach</comment>
<comment xml:lang="nl">Taskcoach</comment>
<comment xml:lang="nn">Taskcoach</comment>
<comment xml:lang="sv">Taskcoach</comment>
<comment xml:lang="uk">Taskcoach</comment>
<comment xml:lang="vi">Taskcoach</comment>
<glob pattern="*.task"/>
<alias type="application/taskcoach"/>
</mime-type>
</mime-info>
You now need to save or copy this new file into the directory
~/.local/share/mime/packages
for a per-user file association or
/usr/share/mime/packages
for a system-wide file association.
Once that is done, run
update-mime-database [MIME-DIRECTORY]
where [MIME-DIRECTORY]
is the previously chosen directory minus the /packages
suffix. (Use sudo
for the system-wide association.)
Now, open your file manager and right-click on anything.task and select taskcoach as the default program with the open with option in the context menu.
Job done. All .task
files will now open with taskcoach!
Best Answer
The Wine page has some detail on this.
First you need
winepath
to translate the path. This will make the script and give it permission to run:Then you'd save something like this to a file called
association.reg
:Then run
regedit association.reg
to add the association to Wine's registry.Note: this is adapted from the Wine page. I got the mime-type from within Linux (
file --mime-type an_avi.avi
). Wine may treat AVI files differently.