mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-15 00:06:09 +03:00
32 lines
826 B
Swift
32 lines
826 B
Swift
import Cocoa
|
|
|
|
extension NSAppearance {
|
|
/// Returns true if the appearance is some kind of dark.
|
|
var isDark: Bool {
|
|
return name.rawValue.lowercased().contains("dark")
|
|
}
|
|
|
|
/// Initialize a desired NSAppearance for the Ghostty configuration.
|
|
convenience init?(ghosttyConfig config: Ghostty.Config) {
|
|
guard let theme = config.windowTheme else { return nil }
|
|
switch (theme) {
|
|
case "dark":
|
|
self.init(named: .darkAqua)
|
|
|
|
case "light":
|
|
self.init(named: .aqua)
|
|
|
|
case "auto":
|
|
let color = OSColor(config.backgroundColor)
|
|
if color.isLightColor {
|
|
self.init(named: .aqua)
|
|
} else {
|
|
self.init(named: .darkAqua)
|
|
}
|
|
|
|
default:
|
|
return nil
|
|
}
|
|
}
|
|
}
|