Colors 如何使用Applescript(或命令行)获取加载的监视器颜色配置文件?

Colors 如何使用Applescript(或命令行)获取加载的监视器颜色配置文件?,colors,applescript,color-management,Colors,Applescript,Color Management,有没有一种方法可以使用Applescript检索加载的监视器颜色配置文件,或者至少使用命令行,因为我可以在Applescript中使用命令行? 我说的是加载的所有插入显示器的颜色配置文件,这些都是在“系统首选项->显示器->颜色”中定义的 编辑:我想获取ICC配置文件的名称,即在“系统首选项”->显示->颜色”中为每个连接的屏幕选择的内容。请尝试以下任一选项: tell application "Image Events" to display profile of displays as li

有没有一种方法可以使用Applescript检索加载的监视器颜色配置文件,或者至少使用命令行,因为我可以在Applescript中使用命令行? 我说的是加载的所有插入显示器的颜色配置文件,这些都是在“系统首选项->显示器->颜色”中定义的

编辑:我想获取ICC配置文件的名称,即在“系统首选项”->显示->颜色”中为每个连接的屏幕选择的内容。

请尝试以下任一选项:

tell application "Image Events" to display profile of displays as list
tell application "Image Events" to display profile of display 1
您可以在Image Suite下的Image Events字典中获得更多(但不是很多)详细信息


显示器0和显示器1似乎产生相同的结果(内置显示器).Display 2指的是外部显示器。我有一个非常简单的设置,因此根据您的设置,您可能需要进行实验。

如果您希望将显示器名称与其颜色配置文件相匹配,则获取显示器名称是pre Catalina系统中的主要问题,但是可以对
system_profiler
实用程序的结果进行调整o获取早期系统中的名称。一点AppleScriptObjC将获取其余名称:

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
使用AppleScript版本“2.4”--约塞米蒂(10.10)或更高版本
使用框架“基础”
使用脚本添加
运行中--示例
将屏幕配置文件设置为“”
将屏幕设置为当前应用程序的NSScreen屏幕
将DisplayName设置为GetDisplayName(屏幕)--处理旧系统
重复i从1到(计数屏幕)
将配置文件设置为屏幕项目i颜色空间的本地化名称
将displayName设置为displayName的第i项
将screenProfiles设置为screenProfiles&“Name:”&displayName&return&“Profile:”&Profile&return&return
结束重复
显示标题为“屏幕颜色配置文件”的对话框屏幕配置文件
终点
获取显示名称(屏幕列表)
将名称设置为{}
如果(获取系统属性“sys2”)>14,则--10.15 Catalina及更高版本
对屏幕列表中的屏幕重复此操作
将名称的末尾设置为屏幕的本地化名称
结束重复
else—munge系统探查器数据
将displayKey设置为“\u iodisplayded”
将nameKey设置为“_name”&返回&tab&tab&tab&tab&tab&tab&tab&tab&tab&”
将displayInfo设置为执行shell脚本“system_profiler-xml SPDisplaysDataType”
将{TENTID,AppleScript的文本项分隔符}设置为{AppleScript的文本项分隔符,displayKey}
将{displayItems,AppleScript的文本项分隔符}设置为{displayInfo的文本项,诱惑ID}
对displayItems的其余部分中的anItem重复此操作
此处设置为(项目中名称键的偏移量)+(名称键的长度)
将其设置为(从此处的文本到anItem的-1的偏移量)-1
将名称的末尾设置为文本here-throu(here+there-1)
结束重复
如果结束
返回theNames
结束getDisplayNames

文档中对列表中的主屏幕进行了讨论。

我在此不建议或提出任何技术建议,因为我没有资格这样做,并且对大家所做的工作印象深刻


我对windows CM(颜色管理)的理解是,虽然许多设备(包括纸张)的许多配置文件都保存在适当的文件夹中,但只有一个可用作系统配置文件。对于监视器配置文件,只有需要或需要“设置”为系统配置文件的内容。如果创建了新的监视器配置文件(通过校准)然后,该系统配置文件将被替换。

此时,它在我的MacBook Pro和Sierra上的一个屏幕上工作得很好。下周我将能够在第二个屏幕上测试脚本。这很好。很方便,我也在使用Sierra,但我认为applescript自那时以来没有改变,因此它应该可以在最新的操作系统版本上工作。顺便说一句,你也可以做一些类似“显示名称为列表”的事情,这应该允许你将显示与配置文件相匹配。使用第二个监视器也很好。我可以循环浏览监视器并检索它们的配置文件,以及每个配置文件名称、创建日期、颜色空间和文件。非常好。你永远不知道这种操作系统/硬件类型是如何工作的这个问题会在其他人的系统上出现,所以我很高兴它能起作用。