From ee4179249155e9973650b7886dfef04d5d9ee374 Mon Sep 17 00:00:00 2001 From: crschnick Date: Sat, 7 Oct 2023 17:19:23 +0000 Subject: [PATCH] macos fixes --- .../xpipe/app/prefs/ExternalTerminalType.java | 39 +++++++++++++++---- .../resources/lang/translations_en.properties | 2 +- .../xpipe/app/resources/style/header-bars.css | 4 -- .../java/io/xpipe/core/process/OsType.java | 2 +- 4 files changed, 34 insertions(+), 13 deletions(-) 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 37c365db9..2c5c24f50 100644 --- a/app/src/main/java/io/xpipe/app/prefs/ExternalTerminalType.java +++ b/app/src/main/java/io/xpipe/app/prefs/ExternalTerminalType.java @@ -380,6 +380,11 @@ public interface ExternalTerminalType extends PrefsChoiceValue { ExternalTerminalType ALACRITTY_MACOS = new MacOsType("app.alacrittyMacOs", "Alacritty") { + @Override + public boolean supportsColoredTitle() { + return false; + } + @Override public void launch(LaunchConfiguration configuration) throws Exception { LocalStore.getShell() @@ -395,16 +400,36 @@ public interface ExternalTerminalType extends PrefsChoiceValue { ExternalTerminalType KITTY_MACOS = new MacOsType("app.kittyMacOs", "kitty") { + @Override + public boolean supportsColoredTitle() { + return false; + } + @Override public void launch(LaunchConfiguration configuration) throws Exception { - try (ShellControl pc = new LocalStore().control().start()) { - pc.command(String.format( + if (!MacOsPermissions.waitForAccessibilityPermissions()) { + return; + } + + try (ShellControl pc = LocalStore.getShell()) { + pc.osascriptCommand(String.format( """ - %s/Contents/MacOS/kitty -T "%s" %s - """, - getApplicationPath().orElseThrow(), - configuration.getTitle(), - pc.getShellDialect().fileArgument(configuration.getScriptFile()))) + if application "Kitty" is running then + tell application "Kitty" to activate + tell application "System Events" to tell process "Kitty" to keystroke "t" using command down + else + tell application "Kitty" to activate + end if + delay 1 + tell application "System Events" + tell process "Kitty" + keystroke "%s" + delay 0.01 + key code 36 + end tell + end tell + """, + configuration.getScriptFile().replaceAll("\"", "\\\\\""))) .execute(); } } diff --git a/app/src/main/resources/io/xpipe/app/resources/lang/translations_en.properties b/app/src/main/resources/io/xpipe/app/resources/lang/translations_en.properties index 5c6ec0b96..5416e6d0b 100644 --- a/app/src/main/resources/io/xpipe/app/resources/lang/translations_en.properties +++ b/app/src/main/resources/io/xpipe/app/resources/lang/translations_en.properties @@ -88,7 +88,7 @@ terminalErrorOccured=A terminal error occured errorTypeOccured=An exception of type $TYPE$ was thrown permissionsAlertTitle=Permissions required permissionsAlertHeader=Additional permissions are required to perform this operation. -permissionsAlertContent=Please follow the pop-up to give XPipe the required permissions in the privacy settings menu. +permissionsAlertContent=Please follow the pop-up to give XPipe the required permissions in the settings menu. errorDetails=Show details target=Target data=Data diff --git a/app/src/main/resources/io/xpipe/app/resources/style/header-bars.css b/app/src/main/resources/io/xpipe/app/resources/style/header-bars.css index 0d19fd1c8..6c874874a 100644 --- a/app/src/main/resources/io/xpipe/app/resources/style/header-bars.css +++ b/app/src/main/resources/io/xpipe/app/resources/style/header-bars.css @@ -13,10 +13,6 @@ -fx-spacing: 0.8em; } -.store-header-bar > .top { - -fx-font-weight: BOLD; -} - .root.nord .store-header-bar { -fx-background-radius: 0; -fx-border-radius: 0; diff --git a/core/src/main/java/io/xpipe/core/process/OsType.java b/core/src/main/java/io/xpipe/core/process/OsType.java index 9ae205909..99efcb05d 100644 --- a/core/src/main/java/io/xpipe/core/process/OsType.java +++ b/core/src/main/java/io/xpipe/core/process/OsType.java @@ -218,7 +218,7 @@ public sealed interface OsType permits OsType.Windows, OsType.Linux, OsType.MacO @Override public Map getProperties(ShellControl pc) throws Exception { try (CommandControl c = - pc.subShell(ShellDialects.BASH).command("sw_vers").start()) { + pc.command("sw_vers").start()) { var text = c.readStdoutOrThrow(); return PropertiesFormatsParser.parse(text, ":"); }