23 lines
814 B
Swift
23 lines
814 B
Swift
import AppKit
|
|
|
|
extension PHConfig {
|
|
/// The per-monitor override that applies to `screen`, if any.
|
|
/// Precedence: monitor name → monitor index.
|
|
func monitorOverride(for screen: NSScreen) -> PHMonitorOverride? {
|
|
let index = NSScreen.screens.firstIndex(of: screen)
|
|
return monitorOverride(screenName: screen.localizedName, screenIndex: index)
|
|
}
|
|
|
|
/// Window definition name for `screen`: the override's `window` if set,
|
|
/// otherwise the global `window`.
|
|
func windowName(for screen: NSScreen) -> String {
|
|
monitorOverride(for: screen)?.window ?? window
|
|
}
|
|
|
|
/// Block-set name for `screen`: the override's `blocks` if set, otherwise
|
|
/// the global `blocks` (defaulting to `"default"`).
|
|
func blocks(for screen: NSScreen) -> String {
|
|
monitorOverride(for: screen)?.blocks ?? (blocks ?? "default")
|
|
}
|
|
}
|