Add support for 'custom' on 'macos_icon' to support a completely custom app icon
parent
29419e7aac
commit
5948bd3f02
|
|
@ -837,6 +837,13 @@ class AppDelegate: NSObject,
|
|||
case .xray:
|
||||
self.appIcon = NSImage(named: "XrayImage")!
|
||||
|
||||
case .custom:
|
||||
if let userIcon = NSImage(contentsOfFile: config.macosCustomIcon) {
|
||||
self.appIcon = userIcon
|
||||
} else {
|
||||
self.appIcon = nil // Revert back to official icon if invalid location
|
||||
}
|
||||
|
||||
case .customStyle:
|
||||
guard let ghostColor = config.macosIconGhostColor else { break }
|
||||
guard let screenColors = config.macosIconScreenColor else { break }
|
||||
|
|
|
|||
|
|
@ -301,6 +301,20 @@ extension Ghostty {
|
|||
return MacOSIcon(rawValue: str) ?? defaultValue
|
||||
}
|
||||
|
||||
var macosCustomIcon: String {
|
||||
let homeDirURL = FileManager.default.homeDirectoryForCurrentUser
|
||||
let ghosttyConfigIconPath = homeDirURL.appendingPathComponent(
|
||||
".config/ghostty/Ghostty.icns",
|
||||
conformingTo: .fileURL).path()
|
||||
let defaultValue = ghosttyConfigIconPath
|
||||
guard let config = self.config else { return defaultValue }
|
||||
var v: UnsafePointer<Int8>? = nil
|
||||
let key = "macos-custom-icon"
|
||||
guard ghostty_config_get(config, &v, key, UInt(key.count)) else { return defaultValue }
|
||||
guard let ptr = v else { return defaultValue }
|
||||
return String(cString: ptr)
|
||||
}
|
||||
|
||||
var macosIconFrame: MacOSIconFrame {
|
||||
let defaultValue = MacOSIconFrame.aluminum
|
||||
guard let config = self.config else { return defaultValue }
|
||||
|
|
|
|||
|
|
@ -280,6 +280,7 @@ extension Ghostty {
|
|||
case paper
|
||||
case retro
|
||||
case xray
|
||||
case custom
|
||||
case customStyle = "custom-style"
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2735,6 +2735,8 @@ keybind: Keybinds = .{},
|
|||
/// * `blueprint`, `chalkboard`, `microchip`, `glass`, `holographic`,
|
||||
/// `paper`, `retro`, `xray` - Official variants of the Ghostty icon
|
||||
/// hand-created by artists (no AI).
|
||||
/// * `custom` - Use a completely custom icon. The location must be specified
|
||||
/// using the additional `macos-custom-icon` configuration
|
||||
/// * `custom-style` - Use the official Ghostty icon but with custom
|
||||
/// styles applied to various layers. The custom styles must be
|
||||
/// specified using the additional `macos-icon`-prefixed configurations.
|
||||
|
|
@ -2753,6 +2755,15 @@ keybind: Keybinds = .{},
|
|||
/// effort.
|
||||
@"macos-icon": MacAppIcon = .official,
|
||||
|
||||
/// The absolute path to the custom icon file.
|
||||
/// Supported formats include PNG, JPEG, and ICNS.
|
||||
///
|
||||
/// Defaults to `~/.config/ghostty/Ghostty.icns`
|
||||
///
|
||||
/// Note: This configuration is required when `macos-icon` is set to
|
||||
/// `custom`
|
||||
@"macos-custom-icon": ?[]const u8 = null,
|
||||
|
||||
/// The material to use for the frame of the macOS app icon.
|
||||
///
|
||||
/// Valid values:
|
||||
|
|
@ -6975,6 +6986,7 @@ pub const MacAppIcon = enum {
|
|||
paper,
|
||||
retro,
|
||||
xray,
|
||||
custom,
|
||||
@"custom-style",
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue