In Systems Preferences -> Displays on OS X it is possible to set the rotation of a connected screen.
Is there anyway I can set this value programmatically?
I can get the current setting using CGDisplayRotation. I seem to be able to set many of the screen properties such as resolution in a simple transaction:
CGDisplayConfigRef config;
CGError error = CGBeginDisplayConfiguration(&config);
...
error = CGCompleteDisplayConfiguration(config, kCGConfigurePermanently);
...but I cannot find anyway to set this specific property.
Has anyone know of a way of doing this?
This can be done by undocumented way. Example sets display orientation on 90 degrease:
CGDirectDisplayID display = CGMainDisplayID();
io_service_t service = CGDisplayIOServicePort(display);
IOOptionBits options = (0x00000400 | (kIOScaleRotate90) << 16);
IOServiceRequestProbe(service, options);
Constants are defined in IOKit.framework IOGraphicsTypes.h
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With