mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-14 07:46:12 +03:00
Merge pull request #1238 from mitchellh/macos-shell
macOS: detect changed shell (via `chsh`) immediately without requiring system restart
This commit is contained in:
@ -1674,16 +1674,22 @@ pub fn finalize(self: *Config) !void {
|
|||||||
// set to /bin/sh.
|
// set to /bin/sh.
|
||||||
if (self.command) |cmd|
|
if (self.command) |cmd|
|
||||||
log.info("shell src=config value={s}", .{cmd})
|
log.info("shell src=config value={s}", .{cmd})
|
||||||
else {
|
else shell_env: {
|
||||||
if (!internal_os.isFlatpak()) {
|
// Flatpak always gets its shell from outside the sandbox
|
||||||
if (std.process.getEnvVarOwned(alloc, "SHELL")) |value| {
|
if (internal_os.isFlatpak()) break :shell_env;
|
||||||
log.info("default shell source=env value={s}", .{value});
|
|
||||||
self.command = value;
|
|
||||||
|
|
||||||
// If we don't need the working directory, then we can exit now.
|
// If we were launched from the desktop, our SHELL env var
|
||||||
if (!wd_home) break :command;
|
// will represent our SHELL at login time. We want to use the
|
||||||
} else |_| {}
|
// latest shell from /etc/passwd or directory services.
|
||||||
}
|
if (internal_os.launchedFromDesktop()) break :shell_env;
|
||||||
|
|
||||||
|
if (std.process.getEnvVarOwned(alloc, "SHELL")) |value| {
|
||||||
|
log.info("default shell source=env value={s}", .{value});
|
||||||
|
self.command = value;
|
||||||
|
|
||||||
|
// If we don't need the working directory, then we can exit now.
|
||||||
|
if (!wd_home) break :command;
|
||||||
|
} else |_| {}
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (builtin.os.tag) {
|
switch (builtin.os.tag) {
|
||||||
|
@ -19,7 +19,15 @@ pub fn launchedFromDesktop() bool {
|
|||||||
return switch (builtin.os.tag) {
|
return switch (builtin.os.tag) {
|
||||||
// macOS apps launched from finder or `open` always have the init
|
// macOS apps launched from finder or `open` always have the init
|
||||||
// process as their parent.
|
// 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
|
// On Linux, GTK sets GIO_LAUNCHED_DESKTOP_FILE and
|
||||||
// GIO_LAUNCHED_DESKTOP_FILE_PID. We only check the latter to see if
|
// GIO_LAUNCHED_DESKTOP_FILE_PID. We only check the latter to see if
|
||||||
|
Reference in New Issue
Block a user