diff --git a/application/MultiMC.cpp b/application/MultiMC.cpp
index 122890d1..baeb9de1 100644
--- a/application/MultiMC.cpp
+++ b/application/MultiMC.cpp
@@ -472,6 +472,9 @@ void MultiMC::initGlobalSettings(bool test_mode)
m_settings->registerSetting("JavaDetectionHack", "");
m_settings->registerSetting("JvmArgs", "");
+ // Wrapper command for launch
+ m_settings->registerSetting("WrapperCommand", "");
+
// Custom Commands
m_settings->registerSetting({"PreLaunchCommand", "PreLaunchCmd"}, "");
m_settings->registerSetting({"PostExitCommand", "PostExitCmd"}, "");
diff --git a/application/pages/global/JavaPage.cpp b/application/pages/global/JavaPage.cpp
index 3daf35dc..d201bb2f 100644
--- a/application/pages/global/JavaPage.cpp
+++ b/application/pages/global/JavaPage.cpp
@@ -70,6 +70,7 @@ void JavaPage::applySettings()
// Custom Commands
s->set("PreLaunchCommand", ui->preLaunchCmdTextBox->text());
+ s->set("WrapperCommand", ui->wrapperCmdTextBox->text());
s->set("PostExitCommand", ui->postExitCmdTextBox->text());
}
void JavaPage::loadSettings()
@@ -86,6 +87,7 @@ void JavaPage::loadSettings()
// Custom Commands
ui->preLaunchCmdTextBox->setText(s->get("PreLaunchCommand").toString());
+ ui->wrapperCmdTextBox->setText(s->get("WrapperCommand").toString());
ui->postExitCmdTextBox->setText(s->get("PostExitCommand").toString());
}
diff --git a/application/pages/global/JavaPage.ui b/application/pages/global/JavaPage.ui
index f9c629c2..f1bc3781 100644
--- a/application/pages/global/JavaPage.ui
+++ b/application/pages/global/JavaPage.ui
@@ -7,7 +7,7 @@
0
0
545
- 609
+ 559
@@ -238,7 +238,7 @@
Custom Commands
- -
+
-
Post-exit command:
@@ -255,9 +255,19 @@
-
- -
+
-
+ -
+
+
+ Wrapper command:
+
+
+
+ -
+
+
@@ -270,7 +280,7 @@
- Pre-launch command runs before the instance launches and post-exit command runs after it exits. Both will be run in MultiMC's working directory with INST_ID, INST_DIR, and INST_NAME as environment variables.
+ <html><head/><body><p>Pre-launch command runs before the instance launches and post-exit command runs after it exits. Both will be run in MultiMC's working directory with INST_ID, INST_DIR, and INST_NAME as environment variables.</p><p>Wrapper command allows running java using an extra wrapper program (like 'optirun' on Linux)</p></body></html>
Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop
@@ -290,11 +300,15 @@
minMemSpinBox
maxMemSpinBox
permGenSpinBox
- javaPathTextBox
javaBrowseBtn
+ javaPathTextBox
jvmArgsTextBox
+ javaDetectBtn
+ javaTestBtn
preLaunchCmdTextBox
+ wrapperCmdTextBox
postExitCmdTextBox
+ tabWidget
diff --git a/logic/BaseInstance.cpp b/logic/BaseInstance.cpp
index 661e4587..0a0bc961 100644
--- a/logic/BaseInstance.cpp
+++ b/logic/BaseInstance.cpp
@@ -42,6 +42,7 @@ BaseInstance::BaseInstance(SettingsObjectPtr globalSettings, SettingsObjectPtr s
// Custom Commands
m_settings->registerSetting({"OverrideCommands","OverrideLaunchCmd"}, false);
m_settings->registerOverride(globalSettings->getSetting("PreLaunchCommand"));
+ m_settings->registerOverride(globalSettings->getSetting("WrapperCommand"));
m_settings->registerOverride(globalSettings->getSetting("PostExitCommand"));
// Console
diff --git a/logic/minecraft/MinecraftProcess.cpp b/logic/minecraft/MinecraftProcess.cpp
index d52eb97c..71dd81ed 100644
--- a/logic/minecraft/MinecraftProcess.cpp
+++ b/logic/minecraft/MinecraftProcess.cpp
@@ -238,8 +238,27 @@ void MinecraftProcess::arm()
QString allArgs = args.join(", ");
emit log("Java Arguments:\n[" + censorPrivateInfo(allArgs) + "]\n\n");
- // instantiate the launcher part
- start(JavaPath, args);
+ QString wrapperCommand = m_instance->settings()->get("WrapperCommand").toString();
+ if(!wrapperCommand.isEmpty())
+ {
+ auto realWrapperCommand = QStandardPaths::findExecutable(wrapperCommand);
+ if (realWrapperCommand.isEmpty())
+ {
+ emit log(tr("The wrapper command \"%1\" couldn't be found.").arg(wrapperCommand), MessageLevel::Warning);
+ m_instance->cleanupAfterRun();
+ emit launch_failed(m_instance);
+ m_instance->setRunning(false);
+ return;
+ }
+ emit log("Wrapper command is:\n" + wrapperCommand + "\n\n");
+ args.prepend(JavaPath);
+ start(wrapperCommand, args);
+ }
+ else
+ {
+ start(JavaPath, args);
+ }
+
if (!waitForStarted())
{
//: Error message displayed if instace can't start