IODisplayConnect is gone in Big Sur of Apple Silicon, what is the replacement?

Viewed 490

I have two Big Sur laptops, one is Intel and other is M1(MacBook Pro M1), when I run command "ioreg | grep -i iodisplayconnect", the Intel one still has it, but M1 system found nothing, anyone know its replacement in M1 Big Sur? I need it to detect display names

2 Answers

I had the same question, but I was looking for IODisplayConnect for the purposes of reading the display brightness.

On a M1 Mac with Big Sur, I found the easiest way to get the brightness info is by running corebrightnessdiag:

$ /usr/libexec/corebrightnessdiag status-info | grep 'DisplayServicesBrightness '
                DisplayServicesBrightness = "0.9302966";

To get and set brightness from code, you can use private APIs from the DisplayServices framework (/System/Library/PrivateFrameworks/DisplayServices.framework):

extern int DisplayServicesGetBrightness(int display, float *brightness);
extern int DisplayServicesSetBrightness(int display, float brightness);

// Change brightness
float brightness = 0.8;
int err = DisplayServicesSetBrightness(1, brightness);

// Get current brightness
err = DisplayServicesGetBrightness(1, &brightness);

Looks like NSScreen is the answer, not perfect since couldn't get other informaiton

Related