mirror of
https://github.com/ghostty-org/ghostty.git
synced 2026-04-14 11:35:48 +00:00
30 lines
840 B
Swift
30 lines
840 B
Swift
import AppKit
|
|
|
|
extension UserDefaults {
|
|
private static let customIconKeyOld = "CustomGhosttyIcon"
|
|
private static let customIconKeyNew = "CustomGhosttyIcon2"
|
|
|
|
var appIcon: AppIcon? {
|
|
get {
|
|
// Always remove our old pre-docktileplugin values.
|
|
defer {
|
|
removeObject(forKey: Self.customIconKeyOld)
|
|
}
|
|
|
|
// Check if we have the new key for our dock tile plugin format.
|
|
guard let data = data(forKey: Self.customIconKeyNew) else {
|
|
return nil
|
|
}
|
|
return try? JSONDecoder().decode(AppIcon.self, from: data)
|
|
}
|
|
|
|
set {
|
|
guard let newData = try? JSONEncoder().encode(newValue) else {
|
|
return
|
|
}
|
|
|
|
set(newData, forKey: Self.customIconKeyNew)
|
|
}
|
|
}
|
|
}
|