0e4ef622 / wine-discord-ipc-bridge

Enable games running under wine to use Discord Rich Presence
MIT License
396 stars 28 forks source link

Need help using this with Steam Play #1

Closed hagabaka closed 4 years ago

hagabaka commented 4 years ago

I saw your comment on Proton's Discord support issue and wanted to try it. The README says the bridge and the game need to be run under the same prefix. So I ran the bridge like

WINEPREFIX="$HOME/.local/share/Steam/steamapps/compatdata/$APPID/pfx" \
"$HOME/.local/share/Steam/steamapps/common/Proton 5.0/dist/bin/wine64" \
/path/to/winediscordipcbridge.exe

And it outputs

wineserver: using server-side synchronization.
Pipe Server: Main thread awaiting client connection on \\.\pipe\discord-ipc-0

However when I try to run the game in Steam, it stays stuck at "running", until I terminate the bridge program, and then the game will run.

I also tried running the bridge in Steam by editing launch options, but it fails right away with

err:ntdll:load_unix_cptable failed to load $HOME/.local/share/Steam/steamapps/common/Proton 5.0/dist/bin/../share/wine/nls/c_20127.nls
ERROR: ld.so: object '$HOME/.local/share/Steam/ubuntu12_32/gameoverlayrenderer.so' from LD_PRELOAD cannot be preloaded (wrong ELF class: ELFCLASS32): ignored.
wineserver: using server-side synchronization.
wine client error:0: version mismatch 621/604.
Your wine binary was not upgraded correctly,
or you have an older one somewhere in your PATH.
Or maybe the wrong wineserver is still running?
0e4ef622 commented 4 years ago

Hi, thanks for the feedback. I looked into this, and found two things.

First, the proton script waits for the current wineserver to terminate, so you'll have to somehow prevent that. I did it by just commenting out the line that waits, which is near the end of the script.

# in {steam library}/steamapps/common/Proton 5.0/proton

    elif sys.argv[1] == "waitforexitandrun":
        #wait for wineserver to shut down
        g_session.run_proc([g_proton.wineserver_bin, "-w"]) <-- comment out this line
        #then run
        g_session.run()

I don't know if there's a better way to do this, but it worked for me.

Second, you'll also need to set WINEESYNC=1 and WINEFSYNC=1 when running the bridge, since that's also something the proton script does.

I tested all this on a game that doesn't use Discord Rich Presence, but this allowed both programs to run at least.

hagabaka commented 4 years ago

Thanks for your response. With these workarounds I got the bridge to run with a few Steam Play games, and at least one of them (Mysterium) is displaying "Now playing" correctly with the bridge. A couple others display it even without the bridge, and some still display "wine-preloader" either way.

I made a shell script which could be used to run the bridge semi-automatically. My intention was to let it run the bridge, wait a few seconds (or scan for the 'awaiting connection' output), and then run the game. However, even though the same command to run the bridge works outside of Steam, it gives a wine client error:0: version mismatch 621/604 error if I run it from within Steam. Would you happen to know why this is? For now, it just uses zenity to display the command to run the bridge.

By replacing proton waitforexitandrun with proton run, it makes the game run without waiting for wineserver to shutdown like your above workaround.

#!/bin/sh

# Run a Steam Play game with wine-discord-ipc-bridge
# Set the game's launch option to: path/to/this-script.sh %command%

BRIDGE="$HOME/.local/bin/winediscordipcbridge.exe"
STEAMDIR="$HOME/.local/share/Steam/steamapps"

PROTONDIR="$(echo "$1" | sed -n 's%^.*\('"$STEAMDIR"'/common/Proton [^/]\+\).*$%\1%p')"
WINE="$PROTONDIR/dist/bin/wine64"
WINEPREFIX="$STEAMDIR/compatdata/$SteamGameId/pfx"

# Display the command to run bridge

zenity --text-info --title 'Run game with Discord IPC Bridge' <<END || exit 1
Run this command, and click OK when it is waiting for connection:

WINEESYNC=1 WINEFSYNC=1 WINEPREFIX='$WINEPREFIX' '$WINE' '$BRIDGE'
END

# Run the bridge automatically - not working

# WINEESYNC=1 WINEFSYNC=1 WINEPREFIX="$WINEPREFIX" "$WINE" "$BRIDGE" &
# sleep 10

# Run the game

"$1" run "${@:3}"
0e4ef622 commented 4 years ago

I played with your script, and there's a really simple fix, just use the actual proton script to run the bridge.

"$1" run "$BRIDGE" &

And apparently the game I was testing with does support Rich Presence, just the bridge wasn't working when it wasn't running under the proton script.

When I run it like this, a terminal window pops up that has the output of the bridge. If the bridge is working properly and the game supports Rich Presence, you should see a bunch of logging in the bridge's output.

e.g.

Pipe Server: Main thread awaiting client connection on \\.\pipe\discord-ipc-0
Client connected
Creating socket
Attempting to connect to /run/user/1000/discord-ipc-0
Connected successfully
48 bytes w->l
347 bytes l->w
65 bytes w->l
61 bytes w->l
69 bytes w->l
65 bytes w->l
61 bytes w->l
69 bytes w->l
hagabaka commented 4 years ago

In that case, could the script be as simple as:

BRIDGE=path/to/winediscordipcbridge.exe
"$1" run "$BRIDGE" &
sleep 10
"$1" run "${@:3}"

Since proton seems to set WINEPREFIX, WINEESYNC and WINEFSYNC already?

Unfortunately, I haven't found a game that is actually connecting to the bridge so far, not even those that are somehow displaying "Now Playing" in Discord...

0e4ef622 commented 4 years ago

Yeah, proton sets all the variables. If you want to try just for the sake of trying, I believe CS:GO is free and you can force it to use Steam Play. The game I was using to test, Muse Dash, is 3 dollars. Both support Rich Presence.

Feel free to open a pull request to add the script to the repo.