This is easily done for a single file type, as answered in How to associate a file type within Wine with a native application?, by creating a .reg
for the desired filetype. But this is for AVI only. I use some wine apps (uTorrent, Soulseek, Eudora, to name a few) that can launch a wide range of files. Email attachments, for example, can be JPG, DOC, PDF, PPS... its impossible (and not desirable) to track down all possible file types that one may receive in an email or download in a torrent.
So I neeed a solution to be more generic and broad. I need the file association to honor whatever native app is currently configured. And I want this to be done for all file types configured in my system.
I've already figured out how to make the solution generic. Simply replacing the launched app in .reg
for winebrowser
, like this:
[HKEY_CLASSES_ROOT\.pdf]
@="PDFfile"
"Content Type"="application/pdf"
[HKEY_CLASSES_ROOT\PDFfile\Shell\Open\command]
@="C:\\windows\\system32\\winebrowser.exe \"%1\""
Ive tested this and it works correctly. Since winebrowser uses xdg-open
as a backend, and converts my windows path to a Unix one, the correct (Linux) app is launched.
So I need a "batch" updater to wine's registry, sort of a wine-update-associations
script that I can run whenever a new app is installed. Maybe a tool that can:
- List all Mime Types types in my system that have a default, installed app associated
- Extract all the needed info (glob, mime type, etc)
- Generate the .REG file in the above format
The tricky part is: i've searched a LOT to find info about how association is done in Ubuntu 10.10 onwards, and documentation is scarce and confusing, to say the least. Freedesktop.org has no complete spec, and even Gnome docs are obsolete. So far I've gathered 4 files that contain association info, but im clueless on which (or why) to use, or how to use them to generate the .reg
file:
~/.local/share/applications/mimeapps.list
~/.local/share/applications/miminfo.cache
/usr/share/applications/miminfo.cache
/etc/gnome/defaults.list
Any help, script or explanation would be greatly appreciated!
Thanks!
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 usespackagekit
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: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!
EDIT:
There is a wine bug about this - which is more of an improvement than a bug. The point is to have
ShellExecute
callxdg-open
, and if not found, look for gnome and kde defaults. You should be able to apply the patch and finally have the magic :-). This solution is cleaner as it does not need messing with the registry.To be more complete here is how to patch and compile wine from source.
END EDIT
I update the wine registry with the script below to add a list of common file types.
You can extend the list to add more types.
It makes use of
/usr/bin/gnome-open
in thegstart.exe
file so it won't work for non-gnome desktops as is.Put this in
conf_wine.sh
:The
gstart.exe
is a bash script..and is the bridge to both worlds:Notes:
gstart.exe
in your current working directory before runningconf_wine.sh
as it will copy it to the.wine
folder.gstart.exe
doesn't have to sit inc:\
.Wine FAQ: How do I associate a native program with a file type in Wine?
I have gathered Info all over the place and have found the following to work:
I have created a file called ~/.wine/drive_c/gstart.exe
with the following :
Then : Created a file called linuxnative.reg in my ~/bin
with the following :
then you do a
regedit linuxnative.reg
Hope this helps.