nriley / brightness

Command-line display brightness control for macOS.
BSD 2-Clause "Simplified" License
605 stars 55 forks source link

Does not work with 5k iMac monitor #10

Closed aarohaa closed 5 years ago

aarohaa commented 8 years ago

bash-3.2# brightness -lv display 0: main, active, awake, online, built-in, ID 0x42bf888 resolution 2560 x 1440 pt (5120 x 2880 px) @ 0.0 Hz, origin (0, 0) physical size 599 x 340 mm IOKit flags 0x7; IOKit display mode ID 0x80005000 usable for desktop GUI, uses OpenGL acceleration brightness: failed to get brightness of display 0x42bf888 (error -536870201) display 1: active, awake, online, external, ID 0x424a392 resolution 2560 x 1440 pt (2560 x 1440 px) @ 0.0 Hz, origin (-2560, -1440) physical size 597 x 336 mm IOKit flags 0x2000007; IOKit display mode ID 0x80005000 usable for desktop GUI, uses OpenGL acceleration display 1: brightness 0.500114 display 2: active, awake, online, external, ID 0x4248d83 resolution 2560 x 1440 pt (2560 x 1440 px) @ 0.0 Hz, origin (-2560, 0) physical size 597 x 336 mm IOKit flags 0x2000007; IOKit display mode ID 0x80005000 usable for desktop GUI, uses OpenGL acceleration display 2: brightness 0.517021

bash-3.2# brightness -d 0 0.1 brightness: failed to set brightness of display 0x42bf888 (error -536870201)

BTW display 1 and 2 are external thunderbolt monitors and do work.

ymukhin commented 8 years ago

I experience the same issue with iMac5k in OS X.

On Thursday, December 3, 2015, aarohaa notifications@github.com wrote:

bash-3.2# brightness -lv display 0: main, active, awake, online, built-in, ID 0x42bf888 resolution 2560 x 1440 pt (5120 x 2880 px) @ 0.0 Hz, origin (0, 0) physical size 599 x 340 mm IOKit flags 0x7; IOKit display mode ID 0x80005000 usable for desktop GUI, uses OpenGL acceleration brightness: failed to get brightness of display 0x42bf888 (error -536870201) display 1: active, awake, online, external, ID 0x424a392 resolution 2560 x 1440 pt (2560 x 1440 px) @ 0.0 Hz, origin (-2560, -1440) physical size 597 x 336 mm IOKit flags 0x2000007; IOKit display mode ID 0x80005000 usable for desktop GUI, uses OpenGL acceleration display 1: brightness 0.500114 display 2: active, awake, online, external, ID 0x4248d83 resolution 2560 x 1440 pt (2560 x 1440 px) @ 0.0 Hz, origin (-2560, 0) physical size 597 x 336 mm IOKit flags 0x2000007; IOKit display mode ID 0x80005000 usable for desktop GUI, uses OpenGL acceleration display 2: brightness 0.517021

bash-3.2# brightness -d 0 0.1 brightness: failed to set brightness of display 0x42bf888 (error -536870201)

BTW display 1 and 2 are external thunderbolt monitors and do work.

— Reply to this email directly or view it on GitHub https://github.com/nriley/brightness/issues/10.

nriley commented 8 years ago

Sorry I don't have a 5K iMac to test with but it must use a different method of adjusting the brightness from what the API I am using supports. Sorry about that!

swrobel commented 8 years ago

@nriley any tips for how to dig for what the correct API is? I have no idea where to start looking.

hcientist commented 8 years ago

also, any hints on how to determine what the error is?I am getting the same error as above (but with 2 displays):

brightness 1
brightness: failed to set brightness of display 0x42bf7fc (error -536870201)
brightness: failed to set brightness of display 0x4248d82 (error -536870201)

what is error -536870201? one of these: https://developer.apple.com/reference/iokit/2011153-iokit_constants ? do i need to iterate through them to figure it out?

nriley commented 8 years ago

@swrobel — You could try enumerating IOKit with any of the many ways to investigate the registry, such as the command line ioreg tool, to see if it is exposed there. Otherwise, you’ll probably have to reverse engineer one of Apple’s frameworks. This is much harder now than when I first did it for the old O3Engine SPIs, because of Apple’s increased use of security measures such as rootless, XPC, encrypted binaries, etc. I don’t have a lot of recent reverse engineering experience in OS X unfortunately so I'm not sure if any of the techniques I could recommend would actually work.

@thegreatmichael — here's a tech Q&A that explains how to decode IOKit error codes:

https://developer.apple.com/library/mac/qa/qa1075/

rhukster commented 5 years ago

FYI, same error (-536870201) with external 2x Thunderbolt 3 - LG 5K displays

nriley commented 5 years ago

If still interested, please check out the changes I made for #21 and see if the current master version works with a 5K iMac display and/or the LG Thunderbolt displays. Thanks!

swrobel commented 5 years ago

@nriley it does seem to work for setting brightness now, but I still can't successfully query brightness for my 2015 5k iMac

$ ./brightness -l 
display 0: main, active, awake, online, built-in, ID 0x42b22ec
./brightness: failed to get brightness of display 0x42b22ec (error -536870201)
nriley commented 5 years ago

@swrobel, thanks for testing. Please try the version I just checked in — it relies on even more private stuff but hopefully should work. I only have 13ʺ MBPs and AirPlay to test with currently, but it seems to work on the former and not on the latter.

swrobel commented 5 years ago

@nriley fantastic, it works now! Thank you!!!