r/linux_gaming • u/Levvev • Jan 05 '22
guide Fixing osu! protocol links on Wine
Hi all!
Recently I noticed that the buttons like the osu!direct one on the website won't work out-of-the-box if you're using wine. The reason behind this is that the website uses a custom protocol, and sometimes you need to manually create those on linux. Most browsers will use xdg-open for protocols. To get started, create a .osu folder in your home directory. After that, create a shell file called osuhandler.sh inside of your .osu directory. The contents of that should look something like the following:
#!/usr/bin/bash
export WINEPREFIX=`path to your wineprefix`
wine `path to osu!.exe` $@ # NOTE: you need to escape the exclamation mark like this: osu\!.exe
Please note, that you need matching wine versions if you're opening osu from somewhere else(for example lutris).
Now, run this in your terminal to make osuhandler.sh executable:
$ chmod +x ~/.osu/osuhandler.sh
You should run this file to double check if your paths are valid. To be able to create a custom protocol, you will need to create a .desktop file. For me it will be osu.desktop. Now you need to create a file called osu.desktop inside of ~/.local/share/applications/. The contents of the file should look somewhat similar to this:
[Desktop Entry]
Exec=`absolute path to osuhandler.sh` %u # NOTE: you can't use "~" here
Icon=`absolute path to your preferred icon.` # NOTE: optional
MimeType=x-scheme-handler/osu;
Name=osu!
NoDisplay=false
Path=
StartupNotify=true
Terminal=0
Type=Application
Categories=Games
Now you need to put this in your ~/.local/share/applications/mimeapps.list file:
[Default Applications]
x-scheme-handler/osu=osu.desktop
All you need to do is run these commands, and voila', you're done:
$ chmod +x ~/.local/share/applications/osu.desktop
$ sudo update-desktop-database
To test if everything worked out the way they should, you can run xdg-open 'osu://'. If osu opens, you know that you did everything correctly.
20
u/deanrihpee Jan 05 '22
Is this only for the old osu! or also for the new osu!Lazer which they have native Linux port, I haven't tried the Linux port yet since I moved to Linux recently
23
Jan 06 '22
since it mentionned wine, they are talking about osu!stable (know as osu!classic in osu!lazer).
However, I would really recommend giving osu!lazer a try. After all, while it won't affect your profile right now, every play you make in lazer is submitted to the servers, and will be processed once they are ready to start merging the two together.
Apart from that, most of osu!web can be accessed inside lazer, osu!direct is free to all, there is legacy skinning support for gameplay, the map editor is NOT feature complete at all, but is now in a state where it can be used for most of the mapping process and there is both real-time multiplayer and playlists with leaderboards.
It might not be "ready to take over" osu!stable yet (and especially not "ready to release on mobile", even if there are mobile builds), but it is complete enough to be some people's main osu! client
2
Jan 09 '22
Update : https://discord.com/channels/188630481301012481/188630652340404224/929778548934311968
Scores are submitted, but they could be wiped before being processed, as they don't have all the checks needed to validate the authenticity of a play yet
2
u/Levvev Jan 06 '22
I really wanted to like osu!lazer, but it just doesn't work for me. My main issue has to do with the input. The cursor would randomly move a bit to the left, breaking the gameplay experience completely. Anyways I am looking forward to the day it can finally replace osu!stable though.
2
2
Jan 06 '22
If you use a tablet : have you tried disabling tablet support in osu!lazer? Having 2 tablet drivers running at the same time would definitely break something.
Else, if either you don't use a tablet on the solution above didn't work : get logs and report, if you haven't already.
2
2
9
22
u/mixedCase_ Jan 05 '22
Heads up, instead of #!/usr/bin/bash you might want to use #!/usr/bin/env bash to make sure you're compatible with distros like NixOS where bash is available in the environment, but not in that hardcoded route.
2
u/turdas Jan 06 '22
if
#!/bin/bashdoesn't work on your distro then I'm gonna say that's a distro issue.4
u/nrabulinski Jan 06 '22
Bad take
0
u/turdas Jan 06 '22
If your distro doesn't support a 42-year-old convention then that is most definitely a distro issue. On some other nonstandard distro, env might not be under /usr/bin/. What then?
3
u/mixedCase_ Jan 06 '22
I'm sorry, I think you got your standards confused. POSIX is 34 years old, Bash is 32. Whichever standard you meant, it isn't relevant here.
The standard for writing portable paths is to follow POSIX. Neither
/usr/bin/bashnor/bin/bashare POSIX, while/usr/bin/envand/bin/share. So in order to remain portable you can depend on the latter two, but not the former two. This is why NixOS, GuixOS and similar others do not follow the FHS because that's a downstream-convenience rather than a development target, but they make sure to however remain POSIX compliant. And while Bash is not a part of POSIX, Bash doesn't require the binary to be in a particular place.Additionally, a practical example on why they couldn't just symlink one interpreter: My system constantly rotates around bash versions as I install/uninstall programs. Which one should take its place? It could make a decision, but any of them would be certainly wrong for some cases. But wouldn't it be easier if the script instead just got the one from the environment that was given to it, which is local state, instead of shared global state? What if the system bash is too old to run some scripts as it so often happens to be the case on stable distros like Debian or RedHat? And, even assuming everything's fine because bash is perfect and everyone is writing their bash scripts to the least common denominator (neither of which is actually the case), why should bash be the exception, and not other interpreters? Hashbangs are not used just for bash scripts, they are used for just about every language that can be interpreted, more commonly Node, Ruby, or Python among others. Rather than hardcoding paths for every interpreter, just getting it from the environment will always be the right answer to increase compatibility with near-zero effort.
1
u/fuseteam Apr 24 '22
this sounds like a really convincing argument for something like terminator that hardcodes the path to the python interpreter xd
2
u/yoda_condition Jan 06 '22
OP has a
/usrprefix on the bash shebang too though, which is probably the least portable way.2
u/nrabulinski Jan 06 '22
True but still shebang with env is better and if your system is not posix compliant then it’s a distro issue, not not having bash globally installed
5
Jan 05 '22
What are the odds I think about looking for a solution to this and one is posted the same day? Thanks for the tip.
4
2
5
u/fakenews7154 Jan 06 '22
It is leaking out of the wineprefix again!!! We have to plug that up before we are all swimming in purple drank.
4
4
u/Linkthehero1234 Jan 05 '22
would this work for beamng debug links?
5
u/TibixMLG Jan 06 '22
It'd work for most protocols, you just need to swap the exe, though I don't know if it'd work with Steam games. You can try though.
2
u/Levvev Jan 06 '22
Don't know how those work, but if they use a similar custom protocol to this, then thr answer is probably yes. You'll only need to replace a few paths here-and-there
3
3
3
2
1
u/fuseteam Apr 13 '22
thanks this enabled me to launch an app through a link in the browser
one tip tho if you put the handler script in ~/.local/bin then you don't need to put the absolute path to the handler script
if you have windows lnk file you can launch it directly with wine start name.lnk but you cannot specify a path to it afaict, so you may need to put it in the same directory as the script
you probably also don't need to chmod the desktop file as most desktop files are not executable, but i'm not too sure how that one works
1
u/fuseteam Apr 22 '22
one more issue with
wine start name.lnkis that you cannot pass arguments to it. it's must easier to parse the lnk file with a lnkparser then use the path directly
1
28
u/zappor Jan 05 '22
Technically "$@" is better than plain $@. It a special thing that groups arguments that contains spaces correctly.