What’s the best way to open a file with a previously installed wine application from within Dolphin using the context menu?
Lutris doesn’t seem to support passing arguments this way and I’ve been unable to figure out how to do it with either WineZGUI or Bottles. I’ve found this discussion [Request]: File association to open file with program installed inside bottle · Issue #2425 · bottlesdevs/Bottles · GitHub but was unable to make the suggested solutions work. The application itself works and dragging a file from Dolphin to the opened application works, too. Only opening a file directly through the context menu doesn’t work. Depending on the solution I tried, either the application opens without opening the file, or the application doesn’t start at all.
Does anyone know how to do this on Bazzite?
I got it to work with the following steps:
Install Bottles and Flatseal from Bazaar.
Use Flatseal to give Bottles access to the files you want the application to open. Check the corresponding entries in the Filesystem section or manually add directories there under “Other files”
Install the Windows application through Bottles.
Make a new text file called “bottles-opener.sh” in “/home/username/.local/bin/” (replace username with your username, without the quotation marks).
Open the file in Kate, copy the following script into it, save:
#!/bin/bash
# Generic Bottles file opener script
# Usage: bottles-opener.sh [FILE] [BOTTLE_NAME] [PROGRAM_NAME]
# Example: bottles-opener.sh "/path/to/file.jpg" "BottleName" "ApplicationName"
if [ "$#" -eq 3 ] && [ -n "$1" ]; then
# File opening mode: file path, bottle name, and program name provided
FILE_PATH="$1"
BOTTLE_NAME="$2"
PROGRAM_NAME="$3"
# Convert Unix path to Windows path for Wine, escaping all problematic shell characters
WINPATH="z:$(echo "$FILE_PATH" | sed 's|/|\\\\|g' | sed 's|\[|\\[|g' | sed 's|\]|\\]|g' | sed 's|(|\\(|g' | sed 's|)|\\)|g' | sed 's|&|\\&|g' | sed 's|;|\\;|g' | sed 's/|/\\|/g')"
# Launch application with file
flatpak run --command=bottles-cli com.usebottles.bottles run -p "$PROGRAM_NAME" -b "$BOTTLE_NAME" -- "$WINPATH"
elif [ "$#" -eq 2 ]; then
# Application launch mode: only bottle and program name provided (no file)
BOTTLE_NAME="$1"
PROGRAM_NAME="$2"
# Launch application without file
flatpak run --command=bottles-cli com.usebottles.bottles run -p "$PROGRAM_NAME" -b "$BOTTLE_NAME"
else
echo "Usage: $0 [FILE] [BOTTLE_NAME] [PROGRAM_NAME]"
echo " or: $0 [BOTTLE_NAME] [PROGRAM_NAME] (launch without file)"
echo ""
echo "Examples:"
echo " $0 \"/path/to/image.jpg\" \"BottleName\" \"ApplicationName\""
echo " $0 \"BottleName\" \"ApplicationName\""
exit 1
fi
Right-click bottles-opener.sh, click Properties, click Permissions, check the option “Allow executing file as program”, click OK.
Right-click on the Application Launcher (the symbol that’s in the bottom left by default). Search for the application. Replace the entry in Program on the right with “/home/username/.local/bin/bottles-opener.sh” (replace username with your username, without the quotation marks) and the entry in Command-line arguments with “%u BottleName ApplicationName” (without the quotation marks, replace BottleName with the name you gave your bottle and ApplicationName with the name of the application as displayed inside your bottle).
You should now be able to open any file in the directories you gave Bottles access to using your Windows application. Note that it won’t work with filenames that contain characters that aren’t supported on Windows.