Ubuntu – How to associate a file type within Wine with a native application

file associationwine

For example, I want all avi files to be associated with mplayer in Wine

mplayer /home/user/myvideo.avi

Edit from Oli: I believe this this actually the inverse of what most people would assume from the original title. Unless I'm mistaken the user is using Total Commander in Wine and would like to launch a Linux-native player on the path. If I'm wrong, just rollback this edit.

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:

mkdir -p ~/bin/
echo '#!/bin/sh' > ~/bin/run_linx_program
echo '$1 "`wine winepath -u "$2"`"' >> ~/bin/run_linx_program
chmod a+x ~/bin/run_linx_program

Then you'd save something like this to a file called association.reg:

[HKEY_CLASSES_ROOT\.avi]
@="AVIfile"
"Content Type"="video/x-msvideo"
[HKEY_CLASSES_ROOT\AVIfile\Shell\Open\command]
@="/bin/sh run_linx_program mplayer \"%1\""

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.