mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-14 15:56:13 +03:00
macos: Make "Settings…" menu item open config file in Application Sup… (#2895)
…port ...unless ~/.config/ghostty/config already exists, then that is opened. (Or whatever $XDG_CONFIG_HOME points to.) If both files exists, ghostty reads first the one in ~/.config/ghostty/config and then the one in Application Support, and merges the settings. In that case, the menu item opens the file at ~/.config. Fixes #2890.
This commit is contained in:
@ -1,4 +1,5 @@
|
||||
const std = @import("std");
|
||||
const builtin = @import("builtin");
|
||||
const Allocator = std.mem.Allocator;
|
||||
const internal_os = @import("../os/main.zig");
|
||||
|
||||
@ -6,7 +7,24 @@ const internal_os = @import("../os/main.zig");
|
||||
/// paths the main config file could be in.
|
||||
pub fn open(alloc_gpa: Allocator) !void {
|
||||
// default location
|
||||
const config_path = try internal_os.xdg.config(alloc_gpa, .{ .subdir = "ghostty/config" });
|
||||
const config_path = config_path: {
|
||||
const xdg_config_path = try internal_os.xdg.config(alloc_gpa, .{ .subdir = "ghostty/config" });
|
||||
|
||||
if (comptime builtin.os.tag == .macos) macos: {
|
||||
// On macOS, use the application support path if the XDG path doesn't exists.
|
||||
if (std.fs.accessAbsolute(xdg_config_path, .{})) {
|
||||
break :macos;
|
||||
} else |err| switch (err) {
|
||||
error.BadPathName, error.FileNotFound => {},
|
||||
else => break :macos,
|
||||
}
|
||||
|
||||
alloc_gpa.free(xdg_config_path);
|
||||
break :config_path try internal_os.macos.appSupportDir(alloc_gpa, "config");
|
||||
}
|
||||
|
||||
break :config_path xdg_config_path;
|
||||
};
|
||||
defer alloc_gpa.free(config_path);
|
||||
|
||||
// Create config directory recursively.
|
||||
|
Reference in New Issue
Block a user