mirror of
https://github.com/xpipe-io/xpipe.git
synced 2024-07-08 15:56:09 +12:00
More mac fixes
This commit is contained in:
parent
1112803a78
commit
4d45617c47
|
@ -38,7 +38,11 @@ public abstract class ExternalApplicationType implements PrefsChoiceValue {
|
|||
|
||||
protected Optional<Path> getApplicationPath() {
|
||||
try (ShellProcessControl pc = ShellStore.local().create().start()) {
|
||||
try (var c = pc.command(String.format("osascript -e 'POSIX path of (path to application \"%s\")'", applicationName)).start()) {
|
||||
try (var c = pc.command(String.format(
|
||||
"/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister " +
|
||||
"-dump | grep -o \"/.*%s.app\" | grep -v -E \"Caches|TimeMachine|Temporary|/Volumes/%s\" | uniq)'",
|
||||
applicationName, applicationName))
|
||||
.start()) {
|
||||
var path = c.readOnlyStdout();
|
||||
if (c.getExitCode() != 0) {
|
||||
return Optional.empty();
|
||||
|
|
|
@ -26,18 +26,19 @@ public interface ExternalTerminalType extends PrefsChoiceValue {
|
|||
}
|
||||
};
|
||||
|
||||
public static final ExternalTerminalType POWERSHELL = new SimpleType("proc.powershell", "powershell", "PowerShell") {
|
||||
public static final ExternalTerminalType POWERSHELL =
|
||||
new SimpleType("proc.powershell", "powershell", "PowerShell") {
|
||||
|
||||
@Override
|
||||
protected String toCommand(String name, String command) {
|
||||
return "powershell.exe -Command " + command;
|
||||
}
|
||||
@Override
|
||||
protected String toCommand(String name, String command) {
|
||||
return "powershell.exe -Command " + command;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSelectable() {
|
||||
return OsType.getLocal().equals(OsType.WINDOWS);
|
||||
}
|
||||
};
|
||||
@Override
|
||||
public boolean isSelectable() {
|
||||
return OsType.getLocal().equals(OsType.WINDOWS);
|
||||
}
|
||||
};
|
||||
|
||||
public static final ExternalTerminalType WINDOWS_TERMINAL =
|
||||
new SimpleType("proc.windowsTerminal", "wt.exe", "Windows Terminal") {
|
||||
|
@ -93,7 +94,7 @@ public interface ExternalTerminalType extends PrefsChoiceValue {
|
|||
}
|
||||
};
|
||||
|
||||
public static final ExternalTerminalType MACOS_TERMINAL = new MacOsType();
|
||||
public static final ExternalTerminalType MACOS_TERMINAL = new MacOsTerminalType();
|
||||
|
||||
public static final ExternalTerminalType ITERM2 = new ITerm2Type();
|
||||
|
||||
|
@ -125,16 +126,18 @@ public interface ExternalTerminalType extends PrefsChoiceValue {
|
|||
|
||||
public abstract void launch(String name, String command) throws Exception;
|
||||
|
||||
static class MacOsType extends ExternalApplicationType.MacApplication implements ExternalTerminalType {
|
||||
static class MacOsTerminalType extends ExternalApplicationType.MacApplication implements ExternalTerminalType {
|
||||
|
||||
public MacOsType() {
|
||||
public MacOsTerminalType() {
|
||||
super("proc.macosTerminal", "Terminal");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void launch(String name, String command) throws Exception {
|
||||
try (ShellProcessControl pc = ShellStore.local().create().start()) {
|
||||
var suffix = command.equals(pc.getShellType().getNormalOpenCommand()) ? "\"\"" : "\"" + command + "\"";
|
||||
var suffix = command.equals(pc.getShellType().getNormalOpenCommand())
|
||||
? "\"\""
|
||||
: "\"" + command.replaceAll("\"", "\\\\\"") + "\"";
|
||||
var cmd = "osascript -e 'tell app \"" + "Terminal" + "\" to do script " + suffix + "'";
|
||||
pc.executeSimpleCommand(cmd);
|
||||
}
|
||||
|
@ -230,7 +233,8 @@ public interface ExternalTerminalType extends PrefsChoiceValue {
|
|||
}
|
||||
}
|
||||
|
||||
public abstract static class SimpleType extends ExternalApplicationType.PathApplication implements ExternalTerminalType {
|
||||
public abstract static class SimpleType extends ExternalApplicationType.PathApplication
|
||||
implements ExternalTerminalType {
|
||||
|
||||
private final String displayName;
|
||||
|
||||
|
|
|
@ -91,4 +91,5 @@ konsole=Konsole
|
|||
xfce=Xfce
|
||||
macosTerminal=Terminal
|
||||
iterm2=iTerm2
|
||||
warp=Warp
|
||||
warp=Warp
|
||||
custom=Custom
|
Loading…
Reference in a new issue