I want to drop XML file on my custom .desktop launcher for this wine application and I can this way. Problem is that if I click on launcher icon to evoke this program, argument z: is always passed on it and that's not acceptable

What are you trying to do btw? Can you add an example?
–
Bruno PereiraDec 10 '11 at 22:10

Hey Bruno ;) I thought it is clear - I made desktop file (purpose - launcher) for wine application and I want to be able to pass file on it. Above z:%f workaround is no good as whenever I launch this wine application argument z: is passed on it and I want to avoid that
–
zetahDec 10 '11 at 22:18

So you have a windows program called (ie) application.exe that you want to pass the current selected file in nautilus to it ie file.txt?
–
Bruno PereiraDec 10 '11 at 22:32

Sorry I should have added example in my first post. I added it now
–
zetahDec 10 '11 at 22:39

I have been having a look around this till now and the only other option for this is a script placed in the exec line that checks for a %f, if it exists launch the application on the file, if not just launch the application. Care for it or is it not an option?
–
Bruno PereiraDec 11 '11 at 1:03

This is the way that just worked for me on a RHEL 6.3 box after some trial and error and reading the Desktop Entry Specification. It's not specific to wine with arguments but it should work with something like Exec=wine \"filename.exe\".

Hope it helps someone as it took me some searching to get it to work.

I think you have to use double quotes and escape them as well as any special characters using a backslash.

An improvement on zetah's answer. This works for passing multiple files to the program. The %f is changed to %F (upper case) to pass all the files dropped, replacing the ^ (for the beginning of the line) with enough of the path name to make it more likely unique, the 'g' at the end of the sed command to cause the replacement to repeat for all files passed and finally the $ instead of the / so that the \ escape characters are not necessary.

Create the .desktop file as you usually do, and simply use this Exec line.

Edit: If your application can handle multiple files in a single instance (for example a multi-tabbed PDF viewer) and you want the current instance to be auto-focused whenever you launch a new file then you need to do the following: