From 8a816dc5ef328472b443f22160dd1c902b1c623d Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Sat, 6 Jan 2024 12:30:44 -0800 Subject: [PATCH] os: mac app launched with bundle env var is treated as desktop launch --- src/os/desktop.zig | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/os/desktop.zig b/src/os/desktop.zig index ed4f977d9..6475c278e 100644 --- a/src/os/desktop.zig +++ b/src/os/desktop.zig @@ -19,7 +19,15 @@ pub fn launchedFromDesktop() bool { return switch (builtin.os.tag) { // macOS apps launched from finder or `open` always have the init // process as their parent. - .macos => c.getppid() == 1, + .macos => macos: { + // This special case is so that if we launch the app via the + // app bundle (i.e. via open) then we still treat it as if it + // was launched from the desktop. + if (build_config.artifact == .lib and + std.os.getenv("GHOSTTY_MAC_APP") != null) break :macos true; + + break :macos c.getppid() == 1; + }, // On Linux, GTK sets GIO_LAUNCHED_DESKTOP_FILE and // GIO_LAUNCHED_DESKTOP_FILE_PID. We only check the latter to see if