mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-15 00:06:09 +03:00
macos: add our application bundle to XDG_DATA_DIRS (#2974)
We're packaging more and more application-specific data directories in our application bundle. It's helpful to add that path to XDG_DATA_DIRS so those applications (that support XDG_DATA_DIRS) can locate their data directories without additional user-level configuration. This also fixes a typo ("MATHPATH") in the nearby MANPATH-building code.
This commit is contained in:
@ -794,26 +794,42 @@ const Subprocess = struct {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add the man pages from our application bundle to MANPATH.
|
// On macOS, export additional data directories from our
|
||||||
if (comptime builtin.target.isDarwin()) {
|
// application bundle.
|
||||||
if (cfg.resources_dir) |resources_dir| man: {
|
if (comptime builtin.target.isDarwin()) darwin: {
|
||||||
var buf: [std.fs.max_path_bytes]u8 = undefined;
|
const resources_dir = cfg.resources_dir orelse break :darwin;
|
||||||
const dir = std.fmt.bufPrint(&buf, "{s}/../man", .{resources_dir}) catch |err| {
|
|
||||||
log.warn("error building manpath, man pages may not be available err={}", .{err});
|
|
||||||
break :man;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
var buf: [std.fs.max_path_bytes]u8 = undefined;
|
||||||
|
|
||||||
|
const xdg_data_dir_key = "XDG_DATA_DIRS";
|
||||||
|
if (std.fmt.bufPrint(&buf, "{s}/..", .{resources_dir})) |data_dir| {
|
||||||
|
try env.put(
|
||||||
|
xdg_data_dir_key,
|
||||||
|
try internal_os.appendEnv(
|
||||||
|
alloc,
|
||||||
|
env.get(xdg_data_dir_key) orelse "/usr/local/share:/usr/share",
|
||||||
|
data_dir,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
} else |err| {
|
||||||
|
log.warn("error building {s}; err={}", .{ xdg_data_dir_key, err });
|
||||||
|
}
|
||||||
|
|
||||||
|
const manpath_key = "MANPATH";
|
||||||
|
if (std.fmt.bufPrint(&buf, "{s}/../man", .{resources_dir})) |man_dir| {
|
||||||
// Always append with colon in front, as it mean that if
|
// Always append with colon in front, as it mean that if
|
||||||
// `MANPATH` is empty, then it should be treated as an extra
|
// `MANPATH` is empty, then it should be treated as an extra
|
||||||
// path instead of overriding all paths set by OS.
|
// path instead of overriding all paths set by OS.
|
||||||
try env.put(
|
try env.put(
|
||||||
"MANPATH",
|
manpath_key,
|
||||||
try internal_os.appendEnvAlways(
|
try internal_os.appendEnvAlways(
|
||||||
alloc,
|
alloc,
|
||||||
env.get("MATHPATH") orelse "",
|
env.get(manpath_key) orelse "",
|
||||||
dir,
|
man_dir,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
} else |err| {
|
||||||
|
log.warn("error building {s}; man pages may not be available; err={}", .{ manpath_key, err });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user