Skip to content

Commit

Permalink
Rough initial 1st Gen + 2nd Gen mixed setup support (5k only)
Browse files Browse the repository at this point in the history
  • Loading branch information
OCJvanDijk committed Jul 12, 2020
1 parent 123b344 commit 7ed3299
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion Brightness Sync/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -271,11 +271,20 @@ class AppDelegate: NSObject, NSApplicationDelegate {
let isOnConsole = (CGSessionCopyCurrentDictionary() as NSDictionary?)?[kCGSessionOnConsoleKey] as? Bool ?? false

if isOnConsole {
let lgVendorNumber = 7789
// let ultraFine5k1stGenModelNumber = 23313
let ultraFine5k2ndGenModelNumber = 23412

let builtin = activeDisplays
.filter { CGDisplayIsBuiltin($0) == 1 }
.compactMap { CGDisplayCreateUUIDFromDisplayID($0)?.takeRetainedValue() }
.first

let source = builtin ?? activeDisplays
.filter { CGDisplayVendorNumber($0) == lgVendorNumber && CGDisplayModelNumber($0) == ultraFine5k2ndGenModelNumber }
.compactMap { CGDisplayCreateUUIDFromDisplayID($0)?.takeRetainedValue() }
.first

let targets = activeDisplays
.filter {
if let displayInfo = CoreDisplay_DisplayCreateInfoDictionary($0)?.takeRetainedValue() as NSDictionary? {
Expand Down Expand Up @@ -303,9 +312,10 @@ class AppDelegate: NSObject, NSApplicationDelegate {
return false
}
}
.filter { CGDisplayModelNumber($0) != ultraFine5k2ndGenModelNumber }
.compactMap { CGDisplayCreateUUIDFromDisplayID($0)?.takeRetainedValue() }

displaysPublisher.send((builtin, targets))
displaysPublisher.send((source, targets))
} else {
displaysPublisher.send((nil, []))
os_log("User not active")
Expand Down

0 comments on commit 7ed3299

Please sign in to comment.