Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Non-Steam Game: Fix StartDir when using GUI #942

Merged
merged 3 commits into from
Oct 18, 2023
Merged

Conversation

sonic2kk
Copy link
Owner

Fixes a problem found when investigating for #941.

Problem

When adding Non-Steam games from the GUI, we still pass -sd even though it's blank, meaning:

  • ${i#*=} is always empty (``)
  • We always set NOSTEXEPATH to "" (which the blank $QEP variable wrapped in quotes)
  • Because of this, the check later on for -z "${NOSTEXEDIR}" will always fail, because it's set to "" (a set of empty quotes).

When adding games from the commandline, this works because under normal circumstances, -sd|--start-dir is not passed. However, if a user passed --start-dir="", then the problem would be the same as above on the GUI.

This means when adding Non-Steam games from the GUI, we end up always writing out "" as the StartDir if the user didn't specify one, whereas we should have been writing out the directory of the EXE. For example, /home/gaben/Games/Sandtrix/sandtrix.exe should have set the StartDir as /home/gaben/Games/Sandtrix, but it isn't - It's using "".

The problem with this is that some games expect to have their working/launch directory be the same as the directory that the EXE is inside of. If StartDir is not set properly, Steam cannot chdir into the directory, and although the game will still launch it will not be using the EXE dir that the game might expect.

Steam's default behaviour is also to use the EXE directory as StartDir when adding Non-Steam games from the client, so we should be following this behaviour regardless (although we were meant to be doing this in the first place, this is a fix for existing functionality).

Solution

The solution is to check to make sure --start-dir is actually defined and actually a directory, before setting it as the StartDir to use. This sanity check makes sure we don't write out invalid path values when adding the Non-Steam Game.

Because of this check, we will also now correctly write out the default value for StartDir, it resolves the issue. Now we match the Steam default behaviour.


Tested this and it should work, so we should be good to merge right away.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant