Two things needed fixing before GIMP would even start. First, GIMP's sandboxed image loader (glycin) uses bubblewrap, which cannot create user namespaces inside a container — fixed with GLYCIN_DISABLE_SANDBOX=1. Second, any process launched from the script died the moment the script exited, because Wine kills all child processes when its own child (the Python script) returns.
Even after solving those, GIMP crashed every time it tried to open a file, with a GTK3 assertion failure inside GtkFileChooserWidget. The same command worked perfectly from the shell. The environment variables were identical. The difference turned out to be invisible to env: Wine installs a seccomp filter on its processes, and that filter is inherited by every child process across fork and exec. No amount of environment tweaking or session detachment can clear an inherited seccomp filter. GTK's file chooser widget makes a syscall during initialisation that Wine's filter blocks, and GIMP crashes.
The fix is to launch GIMP as a transient systemd user service with systemd-run --user --no-block. A process started this way is owned by systemd, not Wine — clean process state, no inherited seccomp filter, completely outside Wine's process tree.
#!/usr/bin/python
import os, sys, subprocess
def convert_wine_path(p):
return p.replace('\\', '/').replace('Z:', '')
env = os.environ.copy()
img_file = convert_wine_path(sys.argv[1]) if len(sys.argv) == 2 else None
cmd = [
'systemd-run', '--user', '--no-block',
'--setenv=GLYCIN_DISABLE_SANDBOX=1',
f'--setenv=DISPLAY={env["DISPLAY"]}',
f'--setenv=HOME={env["HOME"]}',
f'--setenv=XDG_RUNTIME_DIR={env["XDG_RUNTIME_DIR"]}',
'/usr/bin/gimp'
]
if img_file:
cmd.append(img_file)
subprocess.run(cmd)
Save it somewhere on your Linux filesystem, point IrfanView's external editor to the Z: path equivalent, and it works. The same trick applies to any native Linux app you need to launch cleanly from within Wine.