code icon indicating copy to clipboard operation
code copied to clipboard

Support environment variables for the profile hooks

Open EchoEllet opened this issue 1 year ago • 0 comments

Is your suggested enhancement related to a problem? Please describe.

It's not directly related to a specific issue or bug, yet it makes it hard to share instances as we have to hardcode paths like the instance directory or the Java binary executable.

See MultiMC Custom Commands for details.

Describe the solution you'd like

The simplest solution is to simply replace the supported variables like $INST_MC_DIR with something like C:\Users\%USERPROFILE%\AppData\Roaming\com.modrinth.theseus\profiles\Test1on Windows for example, the instance directory path is already available in the current code, we just have to replace it or pass it to for example, allow using it in the commands to run a JAR file that exists in the instance directory.

I suggest to support the following for compatibility:

  1. $INST_NAME: The name of the instance
  2. $INST_ID: The name of the instance's root directory
  3. $INST_DIR: The absolute path to the instance directory
  4. $INST_MC_DIR: Alias for $INST_DIR
  5. $INST_JAVA: The absolute path to the java executable used for launch
  6. $INST_JAVA_ARGS: The JVM parameters used for the launch

As they are widely supported in launchers like MultiMC, Prism Launcher, and even other launchers that are not based on MultiMC.

Describe alternatives you've considered

For now, we will have to hardcode the full path to the Java installed on the launcher and the instance path, making it hard to share with other users.

Additional context

Examples of launchers that support this feature:

image image image

Related issues:

  • #952

This feature request seems to be already in the TODO list: https://github.com/modrinth/code/blob/0f2ddb452cc3baeb85a9a9d1e00dc43ba6b1517d/packages/app-lib/src/api/profile/mod.rs#L781

EchoEllet avatar Jun 24 '24 16:06 EchoEllet