macos: sync NSAppearance for app based on window-theme setting

This commit is contained in:
Mitchell Hashimoto
2023-09-20 21:54:50 -07:00
parent 8963c3b299
commit 3ad39dd5e4
2 changed files with 30 additions and 0 deletions

View File

@@ -71,6 +71,16 @@ extension Ghostty {
_ = ghostty_config_get(config, &v, key, UInt(key.count))
return v;
}
/// The window theme as a string.
var windowTheme: String? {
guard let config = self.config else { return nil }
var v: UnsafePointer<Int8>? = nil
let key = "window-theme"
guard ghostty_config_get(config, &v, key, UInt(key.count)) else { return nil }
guard let ptr = v else { return nil }
return String(cString: ptr)
}
init() {
// Initialize ghostty global state. This happens once per process.