mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-10-15 14:26:09 +00:00
Expand ~
in macos-custom-icon
(#9024)
Since #8999, `macos-custom-icon` works when its a fully expanded absolute path like `/Users/username/dir/icon.icns`, but not when it's abbreviated as `~/dir/icon.icns`. Users were understandably surprised and confused by this. This PR adds tilde expansion using `NSString`s built-in property for this. Also removed a line from the config docs that seemed erroneous. Given that the option has a functional default, it seems incorrect to say that it's required.
This commit is contained in:
@@ -314,17 +314,14 @@ extension Ghostty {
|
|||||||
|
|
||||||
var macosCustomIcon: String {
|
var macosCustomIcon: String {
|
||||||
#if os(macOS)
|
#if os(macOS)
|
||||||
let homeDirURL = FileManager.default.homeDirectoryForCurrentUser
|
let defaultValue = NSString("~/.config/ghostty/Ghostty.icns").expandingTildeInPath
|
||||||
let ghosttyConfigIconPath = homeDirURL.appendingPathComponent(
|
|
||||||
".config/ghostty/Ghostty.icns",
|
|
||||||
conformingTo: .fileURL).path()
|
|
||||||
let defaultValue = ghosttyConfigIconPath
|
|
||||||
guard let config = self.config else { return defaultValue }
|
guard let config = self.config else { return defaultValue }
|
||||||
var v: UnsafePointer<Int8>? = nil
|
var v: UnsafePointer<Int8>? = nil
|
||||||
let key = "macos-custom-icon"
|
let key = "macos-custom-icon"
|
||||||
guard ghostty_config_get(config, &v, key, UInt(key.count)) else { return defaultValue }
|
guard ghostty_config_get(config, &v, key, UInt(key.count)) else { return defaultValue }
|
||||||
guard let ptr = v else { return defaultValue }
|
guard let ptr = v else { return defaultValue }
|
||||||
return String(cString: ptr)
|
guard let path = NSString(utf8String: ptr) else { return defaultValue }
|
||||||
|
return path.expandingTildeInPath
|
||||||
#else
|
#else
|
||||||
return ""
|
return ""
|
||||||
#endif
|
#endif
|
||||||
|
@@ -2872,9 +2872,6 @@ keybind: Keybinds = .{},
|
|||||||
/// Supported formats include PNG, JPEG, and ICNS.
|
/// Supported formats include PNG, JPEG, and ICNS.
|
||||||
///
|
///
|
||||||
/// Defaults to `~/.config/ghostty/Ghostty.icns`
|
/// Defaults to `~/.config/ghostty/Ghostty.icns`
|
||||||
///
|
|
||||||
/// Note: This configuration is required when `macos-icon` is set to
|
|
||||||
/// `custom`
|
|
||||||
@"macos-custom-icon": ?[:0]const u8 = null,
|
@"macos-custom-icon": ?[:0]const u8 = null,
|
||||||
|
|
||||||
/// The material to use for the frame of the macOS app icon.
|
/// The material to use for the frame of the macOS app icon.
|
||||||
|
Reference in New Issue
Block a user