Closed mustdobetter closed 5 years ago
@mustdobetter Ah, I hoped it would be safe to assume that at least all LG UltraFines would have a similar InfoDictionary. I only have one display to test with. That is also the reason I am using getConnectedUltraFineDisplaySerialNumbers at all, because I don't know the serial/vendor/model numbers of the other LG UltraFine models. So I used this hack to search for the "LG UltraFine" string instead in an attempt to catch them all. It does seem like we have the same model though, so the plot thickens...
It seems like you've got the project working in Xcode? It would be interesting to see what CGDisplaySerialNumber(), CGDisplayVendorNumber() and CGDisplayModelNumber() return for your display and if the display info dictionary does contain kDisplayVendorID or kDisplayProductID. If you could put some print() statements here and there to find out that would be of great help and maybe we can figure out how to make this work for everyone.
Thinking about adding a quick “copy diagnostics to clipboard” button to gather precisely this information...
Thanks @OCJvanDijk, I have now created pull request #3 based on your information. I have tested this with the single UltraFine 5k at home. I'm fortunate enough to have 2 of the same at work also so when I'm in the office next week I'll test with these also.
@mustdobetter Thanks for taking the time to help solve this issue. Unfortunately, I failed to properly explain how to gather the necessary info. Your PR works because CGDisplaySerialNumber(display)
will always return a "Not Found" error. This is because display
is an IOKit ID and CGDisplaySerialNumber()
expects a Core Graphics ID which is different.
I just uploaded 1.0.5 with an easy way to gather the necessary diagnostics. Could you try running this version, then opening the menu and press ⌘C to copy the diagnostics and paste them over here?
@OCJvanDijk, no problem - glad to help. I must just add that I'm not a Swift developer - nor do I have much knowledge of Apple OS programming, being foremost a PHP developer. So you'll have to excuse my ignorance when it comes to discussing the technicalities!
Now when you say that CGDisplaySerialNumber(display)
will return a "Not Found", that's not what I'm seeing. It's definitely returning the serial number (see attached), but then so do CGDisplayVendorNumber(display)
and CGDisplayModelNumber(display)
- so there's certainly something I'm not understanding here.
I've attached the output of the diagnostics dump - I hope this helps. Thanks for looking at this. diagnostics.txt
@OCJvanDijk, no problem - glad to help. I must just add that I'm not a Swift developer - nor do I have much knowledge of Apple OS programming, being foremost a PHP developer. So you'll have to excuse my ignorance when it comes to discussing the technicalities!
This is actually my first Swift/iOS/macOS project ever, but I've had some time to study this stuff 🙂.
Now when you say that
CGDisplaySerialNumber(display)
will return a "Not Found", that's not what I'm seeing. It's definitely returning the serial number (see attached), but then so doCGDisplayVendorNumber(display)
andCGDisplayModelNumber(display)
- so there's certainly something I'm not understanding here.
According to the docs:
If I/O Kit cannot identify the monitor: If a monitor is connected to the display, 0x00000000 is returned. If no monitor is connected to the display hardware, 0xFFFFFFFF is returned.
4294967295 equals 0xFFFFFFFF, these low-level APIs can be pretty vague.
But anyway, based on the diagnostics, it seems like we should just compare the vendor number and the model number instead of the serial number. This is also what glfw/glfw@8101d7a does, which was my original inspiration for this code anyway. I'm working on it.
Should be fixed in 1.0.6
Ah good spot! I guess I can be forgiven for thinking this was a valid serial number: "SerialNumber": 4294967295
😊
Version 1.0.6 does seem to work well - thank you! I will test with my additional UltraFines asap and confirm all is working with multiple connected.
Thanks again for doing the hard work to create this utility, and to fix the issue I raised so quickly. Having used these monitors for a couple of years now it's been a constant source of frustration not to have any automatic brightness. As far as I've been able to make out, from the very limited information online, as to why this was omitted, it's that the quality of the sensor within the display is just not up to the job. If the camera is anything to go by I can quite believe it!
@OCJvanDijk , glad to report 1.0.6 works perfectly with multiple UltraFines. I think we can consider this closed. Thanks again.
Firstly, thanks for making this utility public!
Unfortunately the app doesn't work for me with my UltraFine 5k display as there is no serial number returned from the display info. I've got it working by simply ignoring the checks for the display, and simply setting brightness on all non built-in displays. It would be good to understand however why my display is not returning a serial number.
@OCJvanDijk, is this something you've come across before?