maot.dev
menu +
All writing
2 min read

Integrating the system native file manager with Wine

Make applications running through Wine open folders in your native Linux file manager.

This is mostly aimed at osu! mappers/storyboarders who need an easy way to access osu! beatmap folders through Wine.

Introduction

This is a quick tutorial on how you can edit some Wine registry files to make Wine open the native Linux file explorer when clicking the Open folder menu on whatever application uses it, since the explorer.exe application doesn't integrate that well with the Linux environment.

The main use-case for this workaround is for those who need to work with a high bandwidth of files being moved around and shared, edited, or whatever else is needed. e.g. osu! mappers

Doing it

1. Getting the useful info

First of all, you need to locate the path to your osu! prefix:

  • For people using the osu-wine script, by default it's located at ~/.local/share/osu-wine/WINE.win32;
  • For people using Lutris, the installation path is requested at the beginning of the installation process;
  • If you have a custom prefix, you may already know its path.

Important: custom Wine builds

Many osu! players use custom Wine builds to achieve better audio latency. If you happen to do so, get the path of the custom Wine build.

2. Creating the Linux winepath wrapper

Important: make sure ~/.local/bin/ is in your PATH

We will create a shell script in ~/.local/bin/ named run_as_linux:

#!/bin/sh

# This will remove a single quote (') that comes with the argument for some reason
truepath=${2::-1}

# This will execute the first argument with the Unix path provided by the second argument
echo "$truepath" | sed -e 's/\\/\//g' -e 's/://' | sed -r 's/^.{1}//' | xargs -d \\
 $1

Important:

  • Remember to replace /path/to/custom/wine/ with your custom Wine path. If you're using the system Wine, replace it with just wine;
  • After saving the file, remember to set its permissions correctly: chmod +x ~/.local/bin/run_as_linux.

3. Editing the Wine registry

Now we need to set up the Wine prefix to call the wrapper from the application running inside it. To do that, we will create a new registry entry for the Open folder command.

After opening the Wine registry with WINEPREFIX=/path/to/osu/prefix wine regedit, follow these steps:

  1. Create a command key inside HKEY_CLASSES_ROOT\folder\shell\open;
  2. Delete the ddeexec key in HKEY_CLASSES_ROOT\folder\shell\open;
  3. Set the (Default) value to /bin/sh run_as_linux NATIVE_FILE_MANAGER "%1".

Remember to replace NATIVE_FILE_MANAGER with your native file manager binary, such as Nautilus, Dolphin, Thunar, or xdg-open.

Done

You can now open your beatmap folder—or any other folder—in your native file explorer from osu!

References