JSE's Blog

Jonah's blog is here

Discord integration (Discord-RPC) for osu! on Linux/wine and getting Discord working in Wine

- Posted in Uncategorized by

So a while back I posted this video on getting osu! working on linux. It was incredibly low effort (like so low effort I cringe just watching it) so I thought it was hilarious it even has gained the views it has, but whatever. There has always been numerous guides on the internet regarding osu! Linux support, but I've found the best, tried and true method for getting it to just work is to use the Lutris installer. It's not perfect, but it doesn't require any of the tedious tinkering many of the other guides suggest.

As a side note: DO NOT download a low latency/realtime/whatever other kernel to "improve your latency" as other people has suggested. Even many of the pulseaudio tweaks are unnecessary, but especially with these "alternative" kernels, they provide far more downsides than any (imperceivable) "latency improvements" that people say they have. Especially when it comes to FPS microstuttering which will provide a much greater hindrance to your gameplay than any benefit you might gain from a slight improvement to audio latency that, frankly, you wouldn't be able to detect in an A/B test if you wanted to. I even disable the "Reduce pulseaudio latency option in Lutris as I find it provides more issues than gains (specifically, audio out of sync). Anyhow, sorry for that tangent. Now back to the real article...

Now thankfully, osu!lazer is becoming more and more feature complete as the days go by, so soon we will see it eventually support online play, which has full Linux support, but in the mean time wine is where it's at.

Wine is to the point that, with the easy tweak scripts provided by Lutris, the ability to run osu! (and many other Windows only games) on Linux is pretty much flawless. Even the bugs I encountered in the video I made don't seem to happen anymore, at least for me, so it seems things have improved even in the last year or so.

One thing that has changed though is Discord-RPC. You might notice, if you check the Lutris install script, that it fetches a discord-rpc.dll to override the one osu! (used to) provide. Why?

Well the reason goes back to the differences in Windows vs Linux. Discord RPC uses UNIX sockets on Linux for games to communicate with the discord client, but not for Windows of course. The modified discord-rpc.dll file was designed to translate calls on Windows to something Linux can understand, and thus worked with the Linux client. Unfortunately, due to some changes, discord-rpc.dll is no longer in use by osu! it seems, so the file gets instantly deleted from the install, regardless if you copy the modified or originally included discord-rpc.dll file. I read somewhere there is some other discord SDK being used but I haven't researched this at all, but perhaps there is another DLL that could be changed. Or maybe not, I'll look into this some other time perhaps but I found another solution anyway.

Remember wine? The thing we're using to play osu!. Wine implements Windows API calls, so I wondered why we couldn't just get the Windows discord working. This actually worked, to my surprise, as I know Chromium (which Discord uses in the background) has traditionally not played well with Wine.

The new (easy) solution I now use for getting Discord RPC working with osu! on linux is to merely run Discord's windows client itself on the same wine prefix as osu! is running on.

It appears Discord will generally install nicely on wine of any fairly recent version (in my case I'm using wine 4.6 TKG which is what Lutris distributes for the osu! installer). You seem to need .net installed for it to work, but after that the installer, and client will load up correctly. osu! requires .net anyway, so since we're going to be installing it in the same prefix. There doesn't seem to be any other winetricks we need to get this to work. If you are just looking to get it to work in a different prefix though (just don't expect discord-rpc to work unless you install your game in that same prefix) then ensure you got Dotnet 4.5 installed. Now it seems even the Discord overlay is functional.

There are a couple key changes you will need to make in winecfg first though. First, you need to change Wine's windows version from "Windows 2003" (Which is what the Lutris osu! installer sets by default) to "Windows 7". I tried Windows 10 as well, but setting this causes super amounts of lag to the osu! client when you attempt to search your beatmaps. Windows 7 doesn't appear to make any difference from "Windows 2003", at least for me.

Next, and this is important otherwise the discord client would eat my mouse due to this bug, is to disable your Window manager from decorating Wine Windows, which is on the graphics tab of winecfg. Once you make these two tweaks, installing and using discord seems to work fine, and as long as osu! is running after you've opened Discord, RPC will work. If this is all you're after then problem solved! Enjoy your discord RPC integration in osu!.

However you might be tempted to try out this Discord client and use it as a potential alternative to the Linux client, since, after all, Discord is a ram eater so running two discord clients seems a bit undesirable. I was pleasantly surprised at just how much of the client is functional. Even Screen Capturing seems to work better than the Linux client, which only seems to merge all your screens into one.

However, as soon as you make a call or join a voice channel, you'll probably notice Discord will crash and reload, then reattempt to join again, crash, reload. Rinse repeat. If you happen to have it open in a terminal, you'll probably notice the console output say:

wine: Call from 0x7b031dbf to unimplemented function qwave.dll.QOSAddSocketToFlow, aborting
wine: Unimplemented function qwave.dll.QOSAddSocketToFlow called at address 7B031DBF (thread 00f0), starting debugger...

It seems qwave.dll in Wine is just a stub library with unimplemented function calls that don't work, causing the app to crash. Thankfully, this library isn't too special (in contrast to something like kernel32.dll) in that you can easily trade in this DLL for one from Windows and wine will work with this just fine. Of course, this probably violates some Microsoft license, but that's up to you to deal with. Let's just say there are a number of websites on the internet that allows you to download this DLL. Just make sure you get one from something like Windows 7, since I read somewhere there are API calls in newer versions of the library that Wine doesn't support yet. I went with a version 6.0.6001.18000 of the DLL, which I think is from Windows Vista since NT 6.0 was Vista. (6.1 was 7, 6.2 was 8 and 6.3/10 I guess is Windows 10??? So you should probably just avoid the Windows 10 versions and maybe even the Windows 8).

You will need to get this dll and get the 32bit version and paste it into your system32 directory of the wine prefix. If you happen to be using a 64bit prefix, then you will need to paste it into your syswow64 directory instead. In my case, syswow64 doesn't exist as Lutris just makes a 32bit prefix anyway for osu!, so mine was located at /home/jsebean/Games/osu/drive_c/windows/system32/.

Once I did this, I went to winecfg, went to the DLL Overrides section and changed qwave to native since this is a native DLL, not a wine dll, and reloaded discord. Now, connecting to voice channels works perfectly in wine. Hooray!

Now all that's left is to make an easy to use shortcut to launch discord. I did this in Lutris by just hitting the + button in the top left, click "Add Game", enter in the name Discord and pick wine as the runner. Finally, and this is important, you need to clone all of the settings you have from osu! as this runs in the same prefix except for the executable. Be sure to toggle "Show advanced options" at the bottom to see them all. For me, the options are setting the executable (For me, I just set /home/jsebean/Games/osu/drive_c/users/jsebean/Desktop/Discord.lnk). Fore prefix, it's /home/jsebean/Games/osu, set 32bit for the prefix, set the wine version to be identical, and whatever other options are set. Typically "reduce pulseaudio latency" is also set, but I turned this off.

After all that Discord should get it's own launcher in Lutris and you can easily create a shortcut. Everything seems to work now :)

Now here's to hoping we might see this API become available in wine so this wont be needed in the future.

Comments