mirror of
https://github.com/xpipe-io/xpipe.git
synced 2024-09-30 00:56:56 +13:00
Properly init direct terminal launcher for updates
This commit is contained in:
parent
d8b9571de8
commit
e9b0a19509
4 changed files with 22 additions and 24 deletions
|
@ -12,7 +12,6 @@ import io.xpipe.app.util.OptionsBuilder;
|
||||||
import io.xpipe.app.util.TerminalLauncher;
|
import io.xpipe.app.util.TerminalLauncher;
|
||||||
import io.xpipe.core.process.OsType;
|
import io.xpipe.core.process.OsType;
|
||||||
import io.xpipe.core.store.FileNames;
|
import io.xpipe.core.store.FileNames;
|
||||||
import io.xpipe.core.store.LocalStore;
|
|
||||||
import io.xpipe.core.util.XPipeInstallation;
|
import io.xpipe.core.util.XPipeInstallation;
|
||||||
|
|
||||||
public class TroubleshootCategory extends AppPrefsCategory {
|
public class TroubleshootCategory extends AppPrefsCategory {
|
||||||
|
@ -42,14 +41,11 @@ public class TroubleshootCategory extends AppPrefsCategory {
|
||||||
.addComp(
|
.addComp(
|
||||||
new TileButtonComp("launchDebugMode", "launchDebugModeDescription", "mdmz-refresh", e -> {
|
new TileButtonComp("launchDebugMode", "launchDebugModeDescription", "mdmz-refresh", e -> {
|
||||||
OperationMode.executeAfterShutdown(() -> {
|
OperationMode.executeAfterShutdown(() -> {
|
||||||
try (var sc = new LocalStore().control().start()) {
|
var script = FileNames.join(
|
||||||
var script = FileNames.join(
|
XPipeInstallation.getCurrentInstallationBasePath()
|
||||||
XPipeInstallation.getCurrentInstallationBasePath()
|
.toString(),
|
||||||
.toString(),
|
XPipeInstallation.getDaemonDebugScriptPath(OsType.getLocal()));
|
||||||
XPipeInstallation.getDaemonDebugScriptPath(OsType.getLocal()));
|
TerminalLauncher.openDirect("XPipe Debug", sc -> sc.getShellDialect().runScriptCommand(sc, script));
|
||||||
var runScript = sc.getShellDialect().runScriptCommand(sc, script);
|
|
||||||
TerminalLauncher.openDirect("XPipe Debug", sc, runScript);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
e.consume();
|
e.consume();
|
||||||
})
|
})
|
||||||
|
|
|
@ -135,7 +135,7 @@ public class AppInstaller {
|
||||||
exec || read -rsp "Update failed ..."$'\\n' -n 1 key
|
exec || read -rsp "Update failed ..."$'\\n' -n 1 key
|
||||||
""",
|
""",
|
||||||
file, file, name);
|
file, file, name);
|
||||||
TerminalLauncher.openDirect("XPipe Updater", LocalShell.getShell(), command);
|
TerminalLauncher.openDirect("XPipe Updater", sc -> command);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -161,7 +161,7 @@ public class AppInstaller {
|
||||||
exec || read -rsp "Update failed ..."$'\\n' -n 1 key
|
exec || read -rsp "Update failed ..."$'\\n' -n 1 key
|
||||||
""",
|
""",
|
||||||
file, file, name);
|
file, file, name);
|
||||||
TerminalLauncher.openDirect("XPipe Updater", LocalShell.getShell(), command);
|
TerminalLauncher.openDirect("XPipe Updater", sc -> command);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -187,7 +187,7 @@ public class AppInstaller {
|
||||||
exec || echo "Update failed ..." && read -rs -k 1 key
|
exec || echo "Update failed ..." && read -rs -k 1 key
|
||||||
""",
|
""",
|
||||||
file, file, name);
|
file, file, name);
|
||||||
TerminalLauncher.openDirect("XPipe Updater", LocalShell.getShell(), command);
|
TerminalLauncher.openDirect("XPipe Updater", sc -> command);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -10,21 +10,25 @@ import io.xpipe.core.process.ProcessControl;
|
||||||
import io.xpipe.core.process.ProcessControlProvider;
|
import io.xpipe.core.process.ProcessControlProvider;
|
||||||
import io.xpipe.core.process.ShellControl;
|
import io.xpipe.core.process.ShellControl;
|
||||||
import io.xpipe.core.process.TerminalInitScriptConfig;
|
import io.xpipe.core.process.TerminalInitScriptConfig;
|
||||||
|
import io.xpipe.core.util.FailableFunction;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class TerminalLauncher {
|
public class TerminalLauncher {
|
||||||
|
|
||||||
public static void openDirect(String title, ShellControl shellControl, String command) throws Exception {
|
public static void openDirect(String title, FailableFunction<ShellControl,String, Exception> command) throws Exception {
|
||||||
var type = AppPrefs.get().terminalType().getValue();
|
try (var sc = LocalShell.getShell().start()) {
|
||||||
if (type == null) {
|
var type = AppPrefs.get().terminalType().getValue();
|
||||||
throw ErrorEvent.expected(new IllegalStateException(AppI18n.get("noTerminalSet")));
|
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 {
|
public static void open(String title, ProcessControl cc) throws Exception {
|
||||||
|
@ -43,8 +47,7 @@ public class TerminalLauncher {
|
||||||
var adjustedTitle = prefix + cleanTitle;
|
var adjustedTitle = prefix + cleanTitle;
|
||||||
var terminalConfig = new TerminalInitScriptConfig(
|
var terminalConfig = new TerminalInitScriptConfig(
|
||||||
adjustedTitle,
|
adjustedTitle,
|
||||||
type.shouldClear() && AppPrefs.get().clearTerminalOnInit().get(),
|
type.shouldClear() && AppPrefs.get().clearTerminalOnInit().get());
|
||||||
color != null);
|
|
||||||
|
|
||||||
var request = UUID.randomUUID();
|
var request = UUID.randomUUID();
|
||||||
var d = ProcessControlProvider.get().getEffectiveLocalDialect();
|
var d = ProcessControlProvider.get().getEffectiveLocalDialect();
|
||||||
|
|
|
@ -7,9 +7,8 @@ public class TerminalInitScriptConfig {
|
||||||
|
|
||||||
String displayName;
|
String displayName;
|
||||||
boolean clearScreen;
|
boolean clearScreen;
|
||||||
boolean hasColor;
|
|
||||||
|
|
||||||
public static TerminalInitScriptConfig ofName(String name) {
|
public static TerminalInitScriptConfig ofName(String name) {
|
||||||
return new TerminalInitScriptConfig(name, true, false);
|
return new TerminalInitScriptConfig(name, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue