-
-
Notifications
You must be signed in to change notification settings - Fork 480
[Improv]: Add environment variables for use by wrappers #2969
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
[Improv]: Add environment variables for use by wrappers #2969
Conversation
Looks good overall, could you also add it for sideload runner? It might not be useful for your use case, but it's good to have it consistent |
@imLinguin Updated in 8db11ac :) I changed |
src/backend/launcher.ts
Outdated
@@ -275,6 +276,7 @@ async function prepareWineLaunch( | |||
/** | |||
* Maps general settings to environment variables | |||
* @param gameSettings The GameSettings to get the environment variables for | |||
* @param wrapperEnv The wrapper info to be added into the environment variables |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* @param wrapperEnv The wrapper info to be added into the environment variables |
Seems like this was moved to its own function
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I originally tried adding the functionality here, but realized it worked better separate and forgot to reset the documentation. Fixed in 87ee893.
let commandEnv = { | ||
...process.env, | ||
...setupWrapperEnvVars({ appName, appRunner: 'gog' }) | ||
} | ||
if (!isWindows) { | ||
commandEnv = { ...commandEnv, ...setupEnvVars(gameSettings) } | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let commandEnv = { | |
...process.env, | |
...setupWrapperEnvVars({ appName, appRunner: 'gog' }) | |
} | |
if (!isWindows) { | |
commandEnv = { ...commandEnv, ...setupEnvVars(gameSettings) } | |
} | |
let commandEnv = { | |
...process.env, | |
...setupWrapperEnvVars({ appName, appRunner: 'gog' }), | |
...(isWindows ? {} : setupEnvVars(gameSettings)) | |
} |
This feels a little cleaner
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call. Updated in 5d1a6fe.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall looks good.
I left some suggestion/question.
switch (wrapperEnv.appRunner) { | ||
case 'gog': | ||
ret.HEROIC_APP_SOURCE = 'gog' | ||
break | ||
case 'legendary': | ||
ret.HEROIC_APP_SOURCE = 'epic' | ||
break | ||
case 'nile': | ||
ret.HEROIC_APP_SOURCE = 'amazon' | ||
break | ||
case 'sideload': | ||
ret.HEROIC_APP_SOURCE = 'sideload' | ||
break | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not ?
switch (wrapperEnv.appRunner) { | |
case 'gog': | |
ret.HEROIC_APP_SOURCE = 'gog' | |
break | |
case 'legendary': | |
ret.HEROIC_APP_SOURCE = 'epic' | |
break | |
case 'nile': | |
ret.HEROIC_APP_SOURCE = 'amazon' | |
break | |
case 'sideload': | |
ret.HEROIC_APP_SOURCE = 'sideload' | |
break | |
} | |
ret.HEROIC_APP_SOURCE = wrappernEnv.appRunner |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking there could be a case in the future where it may help to distinguish the runner and the source, like if you could choose two different runners for the same store or if one runner supported multiple stores. Not sure if that's a valid/realistic concern given Heroic's design goals.
I added a HEROIC_APP_RUNNER
env var in e78e680. Just let me know if you'd prefer to have HEROIC_APP_SOURCE
removed as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, thanks for that!
This adds two environment variables when launching games:
HEROIC_APP_NAME
andHEROIC_APP_STORE
. Wrapper commands can use these to look up the app info in the Heroic config (e.g., to get the title or Wine prefix for save backup purposes, in my case).I tested this on Windows 11 with GOG and Epic. I don't have any Amazon games, so I wasn't able to test that.
In order to test on my system, I made the
WrappersTable
display on Windows (which I'd like to submit in a separate PR after some testing), then configured a wrapper as a Python script. Main interesting part of the script:I verified that the new environment variables were written out to the log file:
Use the following Checklist if you have changed something on the Backend or Frontend:
I think these environment variables should be documented, but I'm not sure where that information belongs.