diff --git a/app/src/main/java/io/xpipe/app/prefs/TroubleshootCategory.java b/app/src/main/java/io/xpipe/app/prefs/TroubleshootCategory.java index 70fcdb35..08714fce 100644 --- a/app/src/main/java/io/xpipe/app/prefs/TroubleshootCategory.java +++ b/app/src/main/java/io/xpipe/app/prefs/TroubleshootCategory.java @@ -12,7 +12,6 @@ import io.xpipe.app.util.OptionsBuilder; import io.xpipe.app.util.TerminalLauncher; import io.xpipe.core.process.OsType; import io.xpipe.core.store.FileNames; -import io.xpipe.core.store.LocalStore; import io.xpipe.core.util.XPipeInstallation; public class TroubleshootCategory extends AppPrefsCategory { @@ -42,14 +41,11 @@ public class TroubleshootCategory extends AppPrefsCategory { .addComp( new TileButtonComp("launchDebugMode", "launchDebugModeDescription", "mdmz-refresh", e -> { OperationMode.executeAfterShutdown(() -> { - try (var sc = new LocalStore().control().start()) { - var script = FileNames.join( - XPipeInstallation.getCurrentInstallationBasePath() - .toString(), - XPipeInstallation.getDaemonDebugScriptPath(OsType.getLocal())); - var runScript = sc.getShellDialect().runScriptCommand(sc, script); - TerminalLauncher.openDirect("XPipe Debug", sc, runScript); - } + var script = FileNames.join( + XPipeInstallation.getCurrentInstallationBasePath() + .toString(), + XPipeInstallation.getDaemonDebugScriptPath(OsType.getLocal())); + TerminalLauncher.openDirect("XPipe Debug", sc -> sc.getShellDialect().runScriptCommand(sc, script)); }); e.consume(); }) diff --git a/app/src/main/java/io/xpipe/app/update/AppInstaller.java b/app/src/main/java/io/xpipe/app/update/AppInstaller.java index 012beecf..3335a05f 100644 --- a/app/src/main/java/io/xpipe/app/update/AppInstaller.java +++ b/app/src/main/java/io/xpipe/app/update/AppInstaller.java @@ -135,7 +135,7 @@ public class AppInstaller { exec || read -rsp "Update failed ..."$'\\n' -n 1 key """, file, file, name); - TerminalLauncher.openDirect("XPipe Updater", LocalShell.getShell(), command); + TerminalLauncher.openDirect("XPipe Updater", sc -> command); } @Override @@ -161,7 +161,7 @@ public class AppInstaller { exec || read -rsp "Update failed ..."$'\\n' -n 1 key """, file, file, name); - TerminalLauncher.openDirect("XPipe Updater", LocalShell.getShell(), command); + TerminalLauncher.openDirect("XPipe Updater", sc -> command); } @Override @@ -187,7 +187,7 @@ public class AppInstaller { exec || echo "Update failed ..." && read -rs -k 1 key """, file, file, name); - TerminalLauncher.openDirect("XPipe Updater", LocalShell.getShell(), command); + TerminalLauncher.openDirect("XPipe Updater", sc -> command); } @Override diff --git a/app/src/main/java/io/xpipe/app/util/TerminalLauncher.java b/app/src/main/java/io/xpipe/app/util/TerminalLauncher.java index 49c30a10..357a54e3 100644 --- a/app/src/main/java/io/xpipe/app/util/TerminalLauncher.java +++ b/app/src/main/java/io/xpipe/app/util/TerminalLauncher.java @@ -10,21 +10,25 @@ import io.xpipe.core.process.ProcessControl; import io.xpipe.core.process.ProcessControlProvider; import io.xpipe.core.process.ShellControl; import io.xpipe.core.process.TerminalInitScriptConfig; +import io.xpipe.core.util.FailableFunction; import java.io.IOException; +import java.util.List; import java.util.UUID; public class TerminalLauncher { - public static void openDirect(String title, ShellControl shellControl, String command) throws Exception { - var type = AppPrefs.get().terminalType().getValue(); - if (type == null) { - throw ErrorEvent.expected(new IllegalStateException(AppI18n.get("noTerminalSet"))); + public static void openDirect(String title, FailableFunction command) throws Exception { + try (var sc = LocalShell.getShell().start()) { + var type = AppPrefs.get().terminalType().getValue(); + if (type == null) { + throw ErrorEvent.expected(new IllegalStateException(AppI18n.get("noTerminalSet"))); + } + var script = ScriptHelper.constructTerminalInitFile(sc.getShellDialect(), sc, ignored -> null, List.of(), + command.apply(sc), new TerminalInitScriptConfig(title, type.shouldClear() && AppPrefs.get().clearTerminalOnInit().get())); + var config = new ExternalTerminalType.LaunchConfiguration(null, title, title, script, sc.getShellDialect()); + type.launch(config); } - var script = ScriptHelper.createLocalExecScript(command); - var config = new ExternalTerminalType.LaunchConfiguration( - null, title, title, script, shellControl.getShellDialect()); - type.launch(config); } public static void open(String title, ProcessControl cc) throws Exception { @@ -43,8 +47,7 @@ public class TerminalLauncher { var adjustedTitle = prefix + cleanTitle; var terminalConfig = new TerminalInitScriptConfig( adjustedTitle, - type.shouldClear() && AppPrefs.get().clearTerminalOnInit().get(), - color != null); + type.shouldClear() && AppPrefs.get().clearTerminalOnInit().get()); var request = UUID.randomUUID(); var d = ProcessControlProvider.get().getEffectiveLocalDialect(); diff --git a/core/src/main/java/io/xpipe/core/process/TerminalInitScriptConfig.java b/core/src/main/java/io/xpipe/core/process/TerminalInitScriptConfig.java index ce90b69f..e88d9050 100644 --- a/core/src/main/java/io/xpipe/core/process/TerminalInitScriptConfig.java +++ b/core/src/main/java/io/xpipe/core/process/TerminalInitScriptConfig.java @@ -7,9 +7,8 @@ public class TerminalInitScriptConfig { String displayName; boolean clearScreen; - boolean hasColor; public static TerminalInitScriptConfig ofName(String name) { - return new TerminalInitScriptConfig(name, true, false); + return new TerminalInitScriptConfig(name, true); } }