Add themes selector
This commit is contained in:
@@ -19,6 +19,7 @@ class AppDelegate: NSObject, NSApplicationDelegate {
|
||||
observeDisplayPreference()
|
||||
observeSizePreferences()
|
||||
observeFontSizeChanges()
|
||||
observeTerminalThemeChanges()
|
||||
}
|
||||
|
||||
func applicationWillTerminate(_ notification: Notification) {
|
||||
@@ -58,6 +59,16 @@ class AppDelegate: NSObject, NSApplicationDelegate {
|
||||
}
|
||||
.store(in: &cancellables)
|
||||
}
|
||||
|
||||
/// Live-update terminal colors across all sessions.
|
||||
private func observeTerminalThemeChanges() {
|
||||
UserDefaults.standard.publisher(for: \.terminalTheme)
|
||||
.removeDuplicates()
|
||||
.sink { newTheme in
|
||||
TerminalManager.shared.updateAllThemes(TerminalTheme.resolve(newTheme))
|
||||
}
|
||||
.store(in: &cancellables)
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - KVO key paths
|
||||
@@ -67,6 +78,10 @@ private extension UserDefaults {
|
||||
double(forKey: NotchSettings.Keys.terminalFontSize)
|
||||
}
|
||||
|
||||
@objc var terminalTheme: String {
|
||||
string(forKey: NotchSettings.Keys.terminalTheme) ?? NotchSettings.Defaults.terminalTheme
|
||||
}
|
||||
|
||||
@objc var showOnAllDisplays: Bool {
|
||||
bool(forKey: NotchSettings.Keys.showOnAllDisplays)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user