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.1k stars 70 forks source link

Commandline: Add support for Non-Steam Games to getCompatData #970

Closed sonic2kk closed 9 months ago

sonic2kk commented 9 months ago

Another piece for #960.

This PR adds support for Non-Steam Games with getCompatData. We already have partial support, if a game is launched with SteamTinkerLaunch, because we can get the game name and EXE already with existing functions, and we can get the compatdata with the symlink SteamTinkerLaunch creates.

However, for games not launched with SteamTinkerLaunch before, it fails. To resolve this, we can simply generate a default compatdata path. In testing, it looks like Non-Steam Games always have a compatdata created in the Steam Root library folder (i.e. ~/.local/share/Steam/steamapps/compatdata/<appid>). Since we can parse shortcuts.vdf now it's very easy to loop through all shortcuts and simply generate a path like above. As a safety, we check to make sure this actually exists before returning it. We build the return string using the information from shortcuts.vdf even if we have information from earlier in the function, in case the shortcut name has changed or something, just to make sure we have the most up-to-date information.

There is a possibility that the compatdata location assumption is not correct, and that Steam actually creates the compatdata at the "default" library folder. By default Steam does set this to the Steam Root library folder, but it is possible that if Steam uses some other location that this Steam root path will not have the compatdata, and so this command will not find the compatdata. I think that's a big "if" though, so for now, this works :-)


After a shellcheck and some more testing, I think this is good to merge.

sonic2kk commented 9 months ago

Shellcheck is green, doesn't seem to have broken anything, and Steam games still work. This is ready to merge.