diff --git a/app/src/main/java/io/xpipe/app/prefs/ExternalTerminalType.java b/app/src/main/java/io/xpipe/app/prefs/ExternalTerminalType.java index d8f374c24..e70b23a82 100644 --- a/app/src/main/java/io/xpipe/app/prefs/ExternalTerminalType.java +++ b/app/src/main/java/io/xpipe/app/prefs/ExternalTerminalType.java @@ -17,7 +17,7 @@ import java.util.stream.Stream; public interface ExternalTerminalType extends PrefsChoiceValue { - public static final ExternalTerminalType CMD = new SimpleType("app.cmd", "cmd.exe", "cmd.exe") { + ExternalTerminalType CMD = new SimpleType("app.cmd", "cmd.exe", "cmd.exe") { @Override protected String toCommand(String name, String file) { @@ -30,7 +30,7 @@ public interface ExternalTerminalType extends PrefsChoiceValue { } }; - public static final ExternalTerminalType POWERSHELL_WINDOWS = + ExternalTerminalType POWERSHELL_WINDOWS = new SimpleType("app.powershell", "powershell", "PowerShell") { @Override @@ -44,13 +44,13 @@ public interface ExternalTerminalType extends PrefsChoiceValue { } }; - public static final ExternalTerminalType PWSH_WINDOWS = new SimpleType("app.pwsh", "pwsh", "PowerShell Core") { + ExternalTerminalType PWSH_WINDOWS = new SimpleType("app.pwsh", "pwsh", "PowerShell Core") { @Override protected String toCommand(String name, String file) { // Fix for https://github.com/PowerShell/PowerShell/issues/18530#issuecomment-1325691850 var script = ScriptHelper.createLocalExecScript("set \"PSModulePath=\"\r\n\"" + file + "\"\npause"); - return "-ExecutionPolicy Bypass -NoProfile -Command cmd /C '" +script + "'"; + return "-ExecutionPolicy Bypass -NoProfile -Command cmd /C '" + script + "'"; } @Override @@ -59,7 +59,7 @@ public interface ExternalTerminalType extends PrefsChoiceValue { } }; - public static final ExternalTerminalType WINDOWS_TERMINAL = + ExternalTerminalType WINDOWS_TERMINAL = new SimpleType("app.windowsTerminal", "wt.exe", "Windows Terminal") { @Override @@ -77,7 +77,7 @@ public interface ExternalTerminalType extends PrefsChoiceValue { } }; - public static final ExternalTerminalType GNOME_TERMINAL = + ExternalTerminalType GNOME_TERMINAL = new SimpleType("app.gnomeTerminal", "gnome-terminal", "Gnome Terminal") { @Override @@ -105,11 +105,12 @@ public interface ExternalTerminalType extends PrefsChoiceValue { } }; - public static final ExternalTerminalType KONSOLE = new SimpleType("app.konsole", "konsole", "Konsole") { + ExternalTerminalType KONSOLE = new SimpleType("app.konsole", "konsole", "Konsole") { @Override protected String toCommand(String name, String file) { - // Note for later: When debugging konsole launches, it will always open as a child process of IntelliJ/X-Pipe even though we try to detach it. + // Note for later: When debugging konsole launches, it will always open as a child process of + // IntelliJ/X-Pipe even though we try to detach it. // This is not the case for production where it works as expected return "--new-tab -e \"" + file + "\""; } @@ -120,7 +121,7 @@ public interface ExternalTerminalType extends PrefsChoiceValue { } }; - public static final ExternalTerminalType XFCE = new SimpleType("app.xfce", "xfce4-terminal", "Xfce") { + ExternalTerminalType XFCE = new SimpleType("app.xfce", "xfce4-terminal", "Xfce") { @Override protected String toCommand(String name, String file) { @@ -133,15 +134,15 @@ public interface ExternalTerminalType extends PrefsChoiceValue { } }; - public static final ExternalTerminalType MACOS_TERMINAL = new MacOsTerminalType(); + ExternalTerminalType MACOS_TERMINAL = new MacOsTerminalType(); - public static final ExternalTerminalType ITERM2 = new ITerm2Type(); + ExternalTerminalType ITERM2 = new ITerm2Type(); - public static final ExternalTerminalType WARP = new WarpType(); + ExternalTerminalType WARP = new WarpType(); - public static final ExternalTerminalType CUSTOM = new CustomType(); + ExternalTerminalType CUSTOM = new CustomType(); - public static final List ALL = Stream.of( + List ALL = Stream.of( WINDOWS_TERMINAL, PWSH_WINDOWS, POWERSHELL_WINDOWS, @@ -156,7 +157,7 @@ public interface ExternalTerminalType extends PrefsChoiceValue { .filter(terminalType -> terminalType.isSelectable()) .toList(); - public static ExternalTerminalType getDefault() { + static ExternalTerminalType getDefault() { return ALL.stream() .filter(externalTerminalType -> !externalTerminalType.equals(CUSTOM)) .filter(terminalType -> terminalType.isAvailable()) @@ -164,9 +165,9 @@ public interface ExternalTerminalType extends PrefsChoiceValue { .orElse(null); } - public abstract void launch(String name, String file, boolean elevated) throws Exception; + void launch(String name, String file, boolean elevated) throws Exception; - static class MacOsTerminalType extends ExternalApplicationType.MacApplication implements ExternalTerminalType { + class MacOsTerminalType extends ExternalApplicationType.MacApplication implements ExternalTerminalType { public MacOsTerminalType() { super("app.macosTerminal", "Terminal"); @@ -178,19 +179,18 @@ public interface ExternalTerminalType extends PrefsChoiceValue { var suffix = file.equals(pc.getShellDialect().getOpenCommand()) ? "\"\"" : "\"" + file.replaceAll("\"", "\\\\\"") + "\""; - var cmd = String.format( - """ - osascript - "$@" < { if (alert.get() != null) { diff --git a/core/src/main/java/io/xpipe/core/process/ShellControl.java b/core/src/main/java/io/xpipe/core/process/ShellControl.java index ce4f601c7..41b0c54e9 100644 --- a/core/src/main/java/io/xpipe/core/process/ShellControl.java +++ b/core/src/main/java/io/xpipe/core/process/ShellControl.java @@ -37,7 +37,7 @@ public interface ShellControl extends ProcessControl { public void checkRunning() throws Exception; - default CommandControl osaScript(String script) { + default CommandControl osascriptCommand(String script) { return command(String.format( """ osascript - "$@" < { + throw new UnsupportedOperationException(); } case OsType.MacOs macOs -> { + throw new UnsupportedOperationException(); } } } @@ -47,7 +50,11 @@ public class OpenFileWithAction implements LeafAction { @Override public boolean isApplicable(OpenFileSystemModel model, List entries) { - return entries.size() == 1 && entries.stream().noneMatch(entry -> entry.getRawFileEntry().isDirectory()); + var os = model.getFileSystem().getShell(); + return os.isPresent() + && os.get().getOsType().equals(OsType.WINDOWS) + && entries.size() == 1 + && entries.stream().noneMatch(entry -> entry.getRawFileEntry().isDirectory()); } @Override diff --git a/ext/base/src/main/java/io/xpipe/ext/base/browser/OpenNativeFileDetailsAction.java b/ext/base/src/main/java/io/xpipe/ext/base/browser/OpenNativeFileDetailsAction.java index 3665c9369..f20d1633e 100644 --- a/ext/base/src/main/java/io/xpipe/ext/base/browser/OpenNativeFileDetailsAction.java +++ b/ext/base/src/main/java/io/xpipe/ext/base/browser/OpenNativeFileDetailsAction.java @@ -30,7 +30,7 @@ public class OpenNativeFileDetailsAction implements LeafAction { } case OsType.Linux linux -> {} case OsType.MacOs macOs -> { - sc.osaScript(String.format( + sc.osascriptCommand(String.format( """ set fileEntry to (POSIX file "%s") as text tell application "Finder" to open information window of file fileEntry