sonic2kk / steamtinkerlaunch

Linux wrapper tool for use with the Steam client for custom launch options and 3rd party programs
GNU General Public License v3.0
2.03k stars 69 forks source link

Vortex nxm link opening code/pointers (not exactly a feature request) #1112

Closed LucaPisl closed 1 month ago

LucaPisl commented 1 month ago

System Information

Feature Description

Hello. First of all, thank you so much for STL, for someone that is into modding games, this is a blessing.

Now let me also get started by saying this isn't exactly a feature request, more of a cry for help. I've been trying my hardest to get Vortex to open links when running outside of STL, and I just can't get it to work. You definitely managed to get it to somehow work, so I was wondering if I could get some pointers, or perhaps the part of the code that specifically does that. I know that the whole code is available, but I'm not exactly very knowledgeable and after trying to go through the code for about 2 hours, I have to say I'm absolutely lost.

I completely get if this is bothersome, and if you choose to close this issue, but I would highly appreciate if you could help in any way.

Thanks a lot, and again, I have massive respect for this project and lots of appreciation for your work!

sonic2kk commented 1 month ago

Thanks for the kind words and for taking a look at the code first, I appreciate it!

SteamTinkerLaunch v11.11 is very out of date, that is probably the biggest problem. You should be using a version from the master branch. Heck, I wasn't even maintainer when v11.11 was released :wink:

I feel a little bad, but I should stress, SteamTinkerLaunch is not for modding games. The mod tools are almost entirely unmaintained. I took over the project about 18 months ago, so I personally never wrote the code for them or the NXM link handling. Having said that, it did work for me the other day when modding a game with Vortex. A certain game required it, and I decided what the hell, let's suffer and see if SteamTinkerLaunch's Vortex support actually works -- And it did! However Vortex is incredibly hostile to Linux, so I would not expect things to work for very long. STL on master does actually allow you to turn auto-updates and so on off automatically when installing Vortex, and disables pre-releases too. You can also choose a custom Vortex executable.

Someone made some PRs recently for MO2 to attempt to fix the NXM links, perhaps some of those fixes also need applied to Vortex. The relevant PRs are #1082 and #1096. However taking a skim through the code, I'm not seeing what needs changed. One function to check might be setVortexDLMime, which creates the .desktop file that is meant to handle all this association. It may be worth checking if the file this function creates exists at ~/.local/share/applications/vortex-steamtinkerlaunch-dl.desktop and seeing if the information in it is correct. For example, the path in the Exec= line. You can also check if you have a mimeinfo.cache file, and check to see if it has a line x-scheme-handler/nxm=. Then check if it has the name of the .desktop file above in it (may be case-sensitive, unsure). For a manual workaround if it does not, you can create this .desktop file yourself and then update the mimeinfo.cache to have this by either adding the .desktop file name with a semicolon after x-scheme-handler/nxm=, or by creating this on a newline with x-scheme-handler/nxm=vortex-steamtinkerlaunch-dl.desktop (assuming, again, that the file exists).

I would also like to emphasise that, regardless of what program or operating system you are using, to avoid using these kinds of links. If you absolutely must use a mod manager, I urge you to download and install your mod manually. For other programs, where possible, avoid using these kinds of link handlers. They are very prone to breaking (the steam:// ones for the Steam Client rarely work). It is best to avoid reliance on these altogether.

I hope this wasn't rude, you created a very well thought-out issue and were one of the much nicer people on the project when discussing the mod tools (I get a lot of rather entitled and harassing users) so I tried to pay in back in kind, while also trying to outline that I don't really like supporting these tools.


Good luck! I will leave this issue open for a little bit. Hoping for the best, even if I am not very familiar with the modding side :-)

LucaPisl commented 1 month ago

Hey, thank you so much for taking some time to answer!

First of all I completely get that you it's not that good of an idea to support Vortex and modding in general using STL, it's quite the unfortunate situation, but it should hopefully be better once the Nexus Mods App releases with native Linux support. That being said, there are some use-cases where manual modding just isn't do-able, such as Vortex Mod Collections (in my case I use them in multiple games, such as Palworld), where if you try to install (and track) all the mods by hand that would end up taking a lot of time, and you will probably end up with problems along the way. It's simply a much better experience using Vortex with STL, even though it has its problems.

What my issue is about (/ trying to clarify)

Now let me say that I might have not explained all that well what I was trying to do. STL somehow manages to get nxm links to open in already existing instances of Vortex, which is what I am trying to do outside of STL. To be more concrete: I have installed Vortex manually in a Wine prefix, and I am now trying to figure out how to get nxm links to open in that Vortex, just like the STL version of Vortex works. Problem is, I can't seem to get it working at all. I've tried so many different ways of doing it, yet nothing seems to work. So, I've taken to going through the code. So let me also say this: there is nothing wrong with STL's code, and nothing needs to be changed (afaik). This issue is about me trying to replicate what STL is doing with Vortex and NXM links, outside of STL.

Now let me get into a bit more detail: STL works perfectly, and it handles links perfectly, including Vortex link handling. I am able to open Vortex from STL, and then open nxm links in my default browser (I use vivaldi, I highly recommend it btw), which makes Vortex pick up on that and add the mod to the download queue, which is amazing. Looking into vortex-steamtinkerlaunch-dl.desktop I saw the following line: Exec=/home/xeno/stl/prefix/steamtinkerlaunch vortex u %u Now I'm trying to figure out exactly how this works, since it seems that steamtinkerlauncher is the only place on the Internet where someone has figured out how to open nxm links in a running vortex instance in wine.

Summary / conclusion

To conclude, I'm trying to find the specific part of the STL code that has to do with handling Vortex NMX links, and/or anything related to that. As I said, I went through the code, yet could't figure out for the life of me which part has to deal with NMX links. If you, or anybody else could help at all, that would be great. As I said, this is not particularly a STL issue, so I completely get if this gets closed, I appreciate that you even answered.

sonic2kk commented 1 month ago

Ah okay, I think I get you. Basically, you want to know how /home/xeno/stl/prefix/steamtinkerlaunch vortex u %u works?

The long and short of how to do this is that the Vortex executable has an argument you can give it, called -d "nxm://your-nxm-url-here".

This is not Wine-specific, on Windows you can do the same by running from the commandline \path\to\vortex.exe -d "nxm://your-nxm-url-here". However, Wine-specific piece is that you have to make sure you're calling the Vortex executable from the same prefix it's running in. So if it's running in /home/user/wineprefixes/vortex/pfx, you have to make sure that when you're calling the EXE with Wine and setting WINEPREFIX to be the same. I'm going to assume you know what a Wineprefix is here :-)

This allows Vortex to know that it's running and so when you give it -d it will use the currently-running instance. Otherwise it may try to start a separate instance of itself in another prefix (since cross-prefix awareness afaik doesn't exist in Wine). This isn't a problem on Windows because on Windows the whole system is aware of itself, whereas with Wine the program sees the Wine prefix as it's sole "Windows environment".

So if you start Vortex with WINEPREFIX="/home/user/wineprefixes/vortex/pfx" wine /path/to/vortex.exe, then to give this Vortex installation a URL manually, you can run WINEPREFIX="/home/user/wineprefixes/vortex/pfx" wine /path/to/vortex.exe -d "nxm://your-nxm-url-here".

If Vortex is not running, running with the -d parameter will automatically start Vortex and try to install the mod for the last-selected managed Vortex game.

To do this automatically, you need to create a .desktop file as SteamTinkerLaunch does, so something like this: Exec=WINEPREFIX="/home/user/wineprefixes/vortex/pfx" wine /path/to/vortex.exe -d %u. The %u is a special parameter that a .desktop file will substitute for the URL of whatever is passed to it. Think of it as a variable. When you click the Mod Manager Vortex button, Vortex will tell your browser "here's the URL and some other metadata, give it to whatever you're configured to call when this mimetype (in this case, nxm://) is called". So your browser then in this case calls the .desktop file and passes it a whole bunch of info. The .desktop file can access the URL part of this info with %u.


Now for the more technical breakdown of how this is accomplished. I'll try to explain a little, sorry if I go too far back but bear with me:

In short:

I hope that made some sense. Let me know if you need me to clarify anything further!


Also, fwiw, the Mod Collections on NXM are exactly the kind of thing I wish people would avoid. I am not fond of these personally, just funny you used those as your example when that was the exact thing I don't want people to use (not just for Vortex, or Wine, but in general, regardless of program or OS).

P.S., don't forget what I said about making sure you're using STL from master and not v11.11, which is out-of-date by close to 2 years :-)

sonic2kk commented 1 month ago

I am going to close this issue, but feel free to comment if you have anything else you want to ask! :-)

LucaPisl commented 1 month ago

Thank you so much, kind sir! I'm a student in exam session, so I'm sorry for answering so slow. I managed to get it working by doing: WINEPREFIX="/home/xeno/Games/Palworld-prefix/" /home/xeno/.local/share/lutris/runners/wine/lutris-GE-Proton8-26-x86_64/bin/wine /home/xeno/Games/Palworld-prefix/drive_c/Vortex/Vortex.exe -d "<insert-nxm-link--github-doesn't-allow-it>"

WINEPREFIX is self-explanatory, I use the same wine as the one that is currently running the Vortex instance (in this case it's a lutris runner; if you use system wine, you might get some issues), otherwise things go freaky.

I should also add that I am already using STL 12.12, I used the issue template, and forgot to change the version in the template :/ Thank you again, you've been amazing, issue is definitely closed. If it's fine with you, I would like to use this info and make a guide, for others that want to do the same thing as me. Also, I would recommend adding the relevant labels (Vortex, Modding, etc) as I couldn't figure it out, and it could help prevent people asking the same question again.

sonic2kk commented 1 month ago

Ah, no worries about the slow reply! Exam season is tough.

WINEPREFIX="/home/xeno/Games/Palworld-prefix/" /home/xeno/.local/share/lutris/runners/wine/lutris-GE-Proton8-26-x86_64/bin/wine /home/xeno/Games/Palworld-prefix/drive_c/Vortex/Vortex.exe -d "<insert-nxm-link--github-doesn't-allow-it>"

Yep, this looks correct. This is what I tried to explain, so I hope my long explanation helped you here :-)

If it's fine with you, I would like to use this info and make a guide, for others that want to do the same thing as me.

Sure, go ahead! I would only point out two things that might be helpful to add:

  1. This -d flag may be subject to change, as this is something Vortex itself takes. It may not change, but it's worth noting that users should double-check if they're reading in future to see if the Vortex commandline usage changes.
  2. Similarly, Vortex can break under Wine at any time, and it's best to stick to a tested version that is known to at least somewhat work with Wine.

Also, I would recommend adding the relevant labels [...]

Ah, you're absolutely right! Not sure how I forgot that :sweat_smile: Yes, I'll add the Vortex label.

I should also add that I am already using STL 12.12,

You shouldn't be using v12.12 either, you should always be using the latest commit to master, and should regularly update.