From dc93536be99edd897e9ffb580b890a6d0ee3aa98 Mon Sep 17 00:00:00 2001 From: crschnick Date: Wed, 24 Jul 2024 11:18:13 +0000 Subject: [PATCH] Add rosetta check --- .../xpipe/app/core/check/AppRosettaCheck.java | 26 +++++++++++++++++++ .../java/io/xpipe/app/core/mode/BaseMode.java | 2 ++ 2 files changed, 28 insertions(+) create mode 100644 app/src/main/java/io/xpipe/app/core/check/AppRosettaCheck.java diff --git a/app/src/main/java/io/xpipe/app/core/check/AppRosettaCheck.java b/app/src/main/java/io/xpipe/app/core/check/AppRosettaCheck.java new file mode 100644 index 000000000..065d11ba6 --- /dev/null +++ b/app/src/main/java/io/xpipe/app/core/check/AppRosettaCheck.java @@ -0,0 +1,26 @@ +package io.xpipe.app.core.check; + +import io.xpipe.app.core.AppProperties; +import io.xpipe.app.issue.ErrorEvent; +import io.xpipe.app.util.LocalShell; +import io.xpipe.core.process.OsType; + +public class AppRosettaCheck { + + public static void check() throws Exception { + if (OsType.getLocal() != OsType.MACOS) { + return; + } + + if (!AppProperties.get().getArch().equals("x86_64")) { + return; + } + + var ret = LocalShell.getShell().executeSimpleStringCommand("sysctl -n sysctl.proc_translated"); + if (ret.equals("1")) { + ErrorEvent.fromMessage("You are running the Intel version of XPipe on an Apple Silicon system." + + " There is a native build available that comes with much better performance." + + " Please install that one instead."); + } + } +} diff --git a/app/src/main/java/io/xpipe/app/core/mode/BaseMode.java b/app/src/main/java/io/xpipe/app/core/mode/BaseMode.java index ecc3e7d68..7e3d12647 100644 --- a/app/src/main/java/io/xpipe/app/core/mode/BaseMode.java +++ b/app/src/main/java/io/xpipe/app/core/mode/BaseMode.java @@ -7,6 +7,7 @@ import io.xpipe.app.comp.store.StoreViewState; import io.xpipe.app.core.*; import io.xpipe.app.core.check.AppAvCheck; import io.xpipe.app.core.check.AppCertutilCheck; +import io.xpipe.app.core.check.AppRosettaCheck; import io.xpipe.app.core.check.AppShellCheck; import io.xpipe.app.ext.ActionProvider; import io.xpipe.app.ext.DataStoreProviders; @@ -51,6 +52,7 @@ public class BaseMode extends OperationMode { AppSid.init(); LocalShell.init(); AppShellCheck.check(); + AppRosettaCheck.check(); XPipeDistributionType.init(); AppPrefs.setLocalDefaultsIfNeeded(); // Initialize beacon server as we should be prepared for git askpass commands