@@ -53,10 +53,10 @@ class AppDelegate: NSObject, NSApplicationDelegate {
53
53
os_log ( " Starting display refresh... " )
54
54
55
55
let allDisplays = AppDelegate . getAllDisplays ( )
56
- let lgDisplaySerialNumbers = AppDelegate . getConnectedUltraFineDisplaySerialNumbers ( )
56
+ let lgDisplayIdentifiers = AppDelegate . getConnectedUltraFineDisplayIdentifiers ( )
57
57
58
58
let builtin = allDisplays. first { CGDisplayIsBuiltin ( $0) == 1 }
59
- let syncTo = allDisplays. filter { lgDisplaySerialNumbers . contains ( CGDisplaySerialNumber ( $0 ) ) }
59
+ let syncTo = allDisplays. filter { lgDisplayIdentifiers . contains ( DisplayIdentifier ( vendorNumber : CGDisplayVendorNumber ( $0 ) , modelNumber : CGDisplayModelNumber ( $0 ) ) ) }
60
60
61
61
syncTimer? . invalidate ( )
62
62
@@ -115,8 +115,8 @@ class AppDelegate: NSObject, NSApplicationDelegate {
115
115
return Array ( onlineDisplays [ 0 ..< Int ( displayCount) ] )
116
116
}
117
117
118
- static func getConnectedUltraFineDisplaySerialNumbers ( ) -> Set < uint32 > {
119
- var ultraFineDisplays = Set < uint32 > ( )
118
+ static func getConnectedUltraFineDisplayIdentifiers ( ) -> Set < DisplayIdentifier > {
119
+ var ultraFineDisplays = Set < DisplayIdentifier > ( )
120
120
121
121
for displayInfo in getDisplayInfoDictionaries ( ) {
122
122
if
@@ -125,10 +125,11 @@ class AppDelegate: NSObject, NSApplicationDelegate {
125
125
{
126
126
if
127
127
displayName. contains ( " LG UltraFine " ) ,
128
- let serialNumber = displayInfo [ kDisplaySerialNumber] as? UInt32
128
+ let vendorNumber = displayInfo [ kDisplayVendorID] as? UInt32 ,
129
+ let modelNumber = displayInfo [ kDisplayProductID] as? UInt32
129
130
{
130
131
os_log ( " Found compatible display: %{public}@ " , displayName)
131
- ultraFineDisplays. insert ( serialNumber )
132
+ ultraFineDisplays. insert ( DisplayIdentifier ( vendorNumber : vendorNumber , modelNumber : modelNumber ) )
132
133
}
133
134
else {
134
135
os_log ( " Found incompatible display: %{public}@ " , displayName)
@@ -190,4 +191,9 @@ class AppDelegate: NSObject, NSApplicationDelegate {
190
191
@objc func checkForUpdates( ) {
191
192
NSWorkspace . shared. open ( URL ( string: " https://github.com/OCJvanDijk/Brightness-Sync/releases " ) !)
192
193
}
194
+
195
+ struct DisplayIdentifier : Hashable {
196
+ let vendorNumber : UInt32
197
+ let modelNumber : UInt32
198
+ }
193
199
}
0 commit comments