How to associate all file types within Wine with its corresponding native application?

Posted by MestreLion on Ask Ubuntu See other posts from Ask Ubuntu or by MestreLion
Published on 2011-06-30T21:48:16Z Indexed on 2011/07/01 0:30 UTC
Read the original article Hit count: 264

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!

© Ask Ubuntu or respective owner

Related posts about wine

Related posts about shell-scripting