How to get loaded monitor color profile with Applescript (or command line)?

623 Views Asked by At

Is there a way to retreive the loaded monitors color profile with Applescript, or at least with command-line, as I can use command-line in Applescript? I'm talking about the loaded color profile of all plugged monitors, the ones defined in "System Preferences -> displays -> color"

EDIT: I would like to get the name of the ICC profile, i.e. what is selected in "System Preferences" -> displays -> color", for each connected screen.

3

There are 3 best solutions below

4
Mockman On BEST ANSWER

Try either of these:

tell application "Image Events" to display profile of displays as list
tell application "Image Events" to display profile of display 1

You can get more (but not many) details in the Image Events dictionary under Image Suite.

Display 0 and Display 1 both seem to produce the same result (built-in display). Display 2 would refer to an external display. I have a very simple set-up so depending upon yours, you may have to experiment.

0
red_menace On

Getting the display name is the main issue in pre-Catalina systems if you are wanting to match up display names with their color profiles, but results from the system_profiler utility can be massaged to get the names in earlier systems. A little AppleScriptObjC will get the rest:

use AppleScript version "2.4" -- Yosemite (10.10) or later
use framework "Foundation"
use scripting additions

on run -- example
    set screenProfiles to ""
    set theScreens to current application's NSScreen's screens
    set displayNames to getDisplayNames(theScreens) -- handle older systems
    repeat with i from 1 to (count theScreens)
        set profile to localizedName of colorSpace of item i of theScreens
        set displayName to item i of displayNames
        set screenProfiles to screenProfiles & "Name:   " & displayName & return & "Profile:    " & profile & return & return
    end repeat
    display dialog screenProfiles with title "Screen Color Profiles"
end run

to getDisplayNames(screenList)
    set theNames to {}
    if (get system attribute "sys2") > 14 then -- 10.15 Catalina and later
        repeat with screen in screenList
            set end of theNames to localizedName of screen
        end repeat
    else -- munge system profiler data
        set displayKey to "<key>_IODisplayEDID</key>"
        set nameKey to "<key>_name</key>" & return & tab & tab & tab & tab & tab & tab & "<string>"
        set displayInfo to do shell script "system_profiler -xml SPDisplaysDataType"
        set {tempTID, AppleScript's text item delimiters} to {AppleScript's text item delimiters, displayKey}
        set {displayItems, AppleScript's text item delimiters} to {text items of displayInfo, tempTID}
        repeat with anItem in rest of displayItems
            set here to (offset of nameKey in anItem) + (length of nameKey)
            set there to (offset of "</string>" in (text here thru -1 of anItem)) - 1
            set end of theNames to text here thru (here + there - 1) of anItem
        end repeat
    end if
    return theNames
end getDisplayNames

The NSScreen documentation has a discussion about the primary screen in the list.

0
Ian Douglas On

I am not suggesting or making any technical suggestion here as I am not qualified to do so and am hugely impressed by the work you all do.

The way I understand windows CM (colour management) is that while many profiles for many devices (including paper) are held in the appropriate folder only one can be used as the system profile. For the monitor profile only what ever is 'set' as the system profile is wanted or needed. If a new monitor profile is created (via calibration) then that system profile will be replaced.