3

Apple's XDR Displays like the Pro Display XDR and the Liquid Retina Display XDR support Display Reference Modes, also known as Presets. These can be changed from within System Preferences > Displays > Display Settings > Presets (After selecting an XDR Display).

Is there a way to get the list of available Presets and change the current Preset programmatically? Whether it's through a script or through an API? It seems like ColorSync is used to change/set a color profile but I don't see any reference for setting a preset within ColorSync.

Documentation for Reference Modes: https://support.apple.com/en-us/HT210435

edgar_is
  • 126
  • 10
  • As I have neither a **MacBook Pro** with **Liquid Retina XDR** display or **Apple Pro Display XDR**, I cannot say much other than to say if I had one or the other I certainly could use **AppleScript** and **UI Scripting** to make changes as shown in the images in the linked documentation in your question. As to whether or not it can be accomplished in another manner I can't say, sorry. – user3439894 Oct 29 '21 at 18:59
  • @user3439894, Oh wow that would certainly be an option to do this. I hadn't considered UI Scripting. I'll be sure to give that a try for now until I can find a better way. Thanks! – edgar_is Oct 29 '21 at 19:08

2 Answers2

1

If you haven't already succeeded another way you could start from these Applescript lines:

tell application "System Preferences" to activate
tell application "System Events"
    delay 0.2
    click button "Displays" of scroll area 1 of window "System Preferences" of application process "System Preferences"
end tell

Once you have done so (hopefully successful) move your cursor to the next button or pop-up-button, press Cmd-Shift-4 and:
 take a note of coordinates ([X], [Y]).
 put these into a new script tell application "System Events" to click at {[X], [Y]}.
   This script will in its "results" part show a definition of this (pop-up-) button (must be visible).
 append the definition after the first "click"-line (above) supplemented by click at the beginning (minus: of application "System Events") plus delay.
 Repeat these steps for every "level" of selections you need for your goal.
(I suggest you test the script after every appendix…)

clemsam lang
  • 440
  • 3
  • 11
1

Yes, it can be done by compiling against the private MonitorPanel.framework which is what System Settings uses to change resolutions and presets.

Here is a simple Swift file that can list and change presets along with the required headers to compile it. I also provide a compiled binary and Apple Shortcuts support in lunar.fyi for convenience.

And here's some sample code to list displays with their active preset, then activating the "Design & Print (P3-D50)" preset for the first display.

presets.swift

guard let mgr = MPDisplayMgr(), let display = mgr.displays.first(where: \.hasPresets) else {
    exit(1)
}

print("\(display.displayName!): \"\(display.activePreset!.presetName!)\"")

if let preset = display.presets.first(where: { $0.presetName == "Design & Print (P3-D50)" }) {
    print("Activating preset \"Design & Print (P3-D50)\" for \(display.displayName!)")
    display.setActivePreset(preset)
}

Bridging-Header.h

#import <MonitorPanel/MPDisplayPreset.h>
#import <MonitorPanel/MPDisplay.h>
#import <MonitorPanel/MPDisplayMgr.h>
#import <MonitorPanel/MPDisplayMode.h>

Compiler command:

swiftc -F$PWD/Headers \
    -F/System/Library/PrivateFrameworks \
    -framework MonitorPanel \
    -import-objc-header Bridging-Header.h \
    presets.swift -o presets
./presets
Alin Panaitiu
  • 398
  • 2
  • 6