From e2937448bbe287b91ce1cce452bd42c9e631a72d Mon Sep 17 00:00:00 2001 From: -k Date: Mon, 16 Jun 2025 00:30:51 -0400 Subject: [PATCH] fix: get GTK env var on FreeBSD --- src/os/desktop.zig | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/os/desktop.zig b/src/os/desktop.zig index bb3bbc315..fd1453627 100644 --- a/src/os/desktop.zig +++ b/src/os/desktop.zig @@ -30,24 +30,24 @@ pub fn launchedFromDesktop() bool { break :macos c.getppid() == 1; }, - // On Linux, GTK sets GIO_LAUNCHED_DESKTOP_FILE and + // On Linux and BSD, GTK sets GIO_LAUNCHED_DESKTOP_FILE and // GIO_LAUNCHED_DESKTOP_FILE_PID. We only check the latter to see if // we match the PID and assume that if we do, we were launched from // the desktop file. Pid comparing catches the scenario where // another terminal was launched from a desktop file and then launches // Ghostty and Ghostty inherits the env. - .linux => linux: { + .linux, .freebsd => ul: { const gio_pid_str = posix.getenv("GIO_LAUNCHED_DESKTOP_FILE_PID") orelse - break :linux false; + break :ul false; const pid = c.getpid(); const gio_pid = std.fmt.parseInt( @TypeOf(pid), gio_pid_str, 10, - ) catch break :linux false; + ) catch break :ul false; - break :linux gio_pid == pid; + break :ul gio_pid == pid; }, // TODO: This should have some logic to detect this. Perhaps std.builtin.subsystem @@ -56,9 +56,6 @@ pub fn launchedFromDesktop() bool { // iPhone/iPad is always launched from the "desktop" .ios => true, - // Assume we are launching from the "desktop" - .freebsd => true, - else => @compileError("unsupported platform"), }; }