bottlesdevs / Bottles

Run Windows software and games on Linux
https://usebottles.com
GNU General Public License v3.0
6.06k stars 257 forks source link

[Request]: File association to open file with program installed inside bottle #2425

Open tazihad opened 1 year ago

tazihad commented 1 year ago

Tell us the problem or your need

I want to open .doc, docx file with office program WINWORD.EXE installed in a bottle. simply passing the argument doesn't work. ex - flatpak run --command=bottles-cli com.usebottles.bottles run -p WINWORD -b Office2007 --args "/var/home/zihad/Downloads/wo_pbc_15_4.doc"

Someone posted some tweaks in forum which unfortunately doesn't work.

We want some option to associate some document or other file to open with program installed inside bottles.

Describe the solution you'd like

Other solutions?

No response

Additional context and references

No response

silviucc commented 1 year ago

Yeah,

I have a similar issue with trying to open .rar archives using WinRAR.

By looking in the .desktop file they just pass the %u argument to WinRAR, which is not how it should be done. The path needs to be converted to something a Windows program understands. With pure wine it should work by using winepath.

Once passing file paths to the Windows program is fixed, you could associate various file extension via the "Open With" context menu entry in your file manager

caranology commented 1 year ago

The only one solution that worked for me was: flatpak run --command=bottles-cli com.usebottles.bottles run -b 'Software_bottle' -e "/home/full_path_to_exe/word.exe" --args "/home/full_path_to_file/file.doc or flatpak run --command=bottles-cli com.usebottles.bottles run -b 'Software_bottle' -e "/home/full_path_to_exe/word.exe" --args %f for .desktop file for some reason -a option doesn't work but --args does, no idea why. For browser application links it is sometimes necessary to use double brackets like '"%u"'

But yeah the state of bottles-cli for today is barely working.

ftdt10 commented 6 months ago

It needs drive letter and double quotes in the --args like below in .desktop file. Exec=flatpak run --command=bottles-cli com.usebottles.bottles run -b BOTTLE_NAME -e PATH_TO_EXE --args "z:%F" Terminal=false

And, if an error message pops up saying "Bottles is not responding" when opening multiple files in one program, write the following in a desktop file and launch the WINE cmd.exe utility in advance to resolve the issue. Exec=flatpak run --command=bottles-cli com.usebottles.bottles tools -b BOTTLE_NAME cmd Terminal=true

Sollace commented 6 months ago

It needs drive letter and double quotes in the --args like below in .desktop file. Exec=flatpak run --command=bottles-cli com.usebottles.bottles run -b BOTTLE_NAME -e PATH_TO_EXE --args "z:%F" Terminal=false

And, if an error message pops up saying "Bottles is not responding" when opening multiple files in one program, write the following in a desktop file and launch the WINE cmd.exe utility in advance to resolve the issue. Exec=flatpak run --command=bottles-cli com.usebottles.bottles tools -b BOTTLE_NAME cmd Terminal=true

Ah, thank you! Single quotes did the trick.

I think I figured out what I need. Using this for my file association:

run --command=bottles-cli com.usebottles.bottles run -p Inkscape -b Common -- '"%U"'

Exec=flatpak run --command=bottles-cli com.usebottles.bottles run -p Inkscape -b Common -- '"%U"'

(Edit, sorry, meant to reply to the comment in #3234 )

tazihad commented 6 months ago

@ftdt10 yours works. But if there's a space in document file name. It won't work.

ftdt10 commented 6 months ago

A) steps for file association to open file with Bottles program. using Nautilus file manager. Add desktop entry using this guide. Edit the added .desktop file at ~/.local/share/applications folder as described in https://github.com/bottlesdevs/Bottles/issues/2425#issuecomment-1880785975. In Nautilus, right-click a file with the extension, click "Open With", choose the Bottles app in the list and check "Always use for this file type". Then double-click the extension file in Nautilus.

B) to open file using terminal CLI Add single quotes if space exists in file/folder name, prepend drive letter, and wrap it with double quotes. flatpak run --command=bottles-cli com.usebottles.bottles run -b BOTTLE_NAME -e PATH_TO_EXE --args "z:'/home/USER/dir abc/file test.ext'"

It needs also directory expose like this guide


If filename has special characters such as single quote, colon, and etc, add additional backslash and single quotes. '\'' '\:'

ex) if filename is /home/USER/abc's file flatpak run --command=bottles-cli com.usebottles.bottles run -b BOTTLE_NAME -e PATH_TO_EXEC --args "z:'/home/USER/abc'\''s file'"

NeoFoxxo commented 5 months ago

I got it to work with files on Dolphin with whitespace using this: run -b BOTTLE_NAME -e EXE_PATH --args 'z:'\''%F'\'''

shrublet commented 4 months ago

Just chiming in with the only solution that worked (for a .desktop file) for me that prepends the drive and converts forward slashes to (double) backwards slashes. %U should be replacable with other options too (%u, %f, etc.). Exec=bash -c "flatpak run --command=bottles-cli com.usebottles.bottles run -p 'PROGRAM NAME' -b 'BOTTLE NAME' -- $(echo \\'z:%U\\' | sed 's!/!\\\\\\\\\\\\\\\\!g')"

vms4819 commented 3 weeks ago

As an addendum, I added escaped double-quotes to allow for spaces in filenames in @shrublet 's response:

Exec=bash -c "bottles-cli run -p WINWORD -b 'Office2007' -- $(echo \\'z:\\"%f\\"\\' | sed 's!/!\\\\\\\\\\\\\\\\!g')"

tazihad commented 3 weeks ago

@vms4819 Thanks for your solution. I think files and folder with double spaces works now. Here's mine that works:
Exec=bash -c "flatpak run --command=bottles-cli com.usebottles.bottles run -p 'WINWORD' -b 'Office2007' -- $(echo \\'z:\\"%f\\"\\' | sed 's!/!\\\\\\\\\\\\\\\\!g')"