Apple Silicon Mac 获取显示器 Product ID 和 Vendor ID

Apple Silicon Mac 上对显示器配置进行修改时,往往需要用到 Product IDVendor ID 信息,使用下面的命令可以轻松获取到 ⚡

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# 查看 CPU 信息
AS=$(sysctl -n machdep.cpu.brand_string|grep Apple|wc -l)
# 如果是 Apple Silicon Mac
if [ $AS = "1" ];then
vids=$(printf "%x\n" $(ioreg -l|grep -i "DisplayAttributes"|grep -Eo "\"LegacyManufacturerID\"=\d*"|awk -F'=' '{print $NF}'))
pids=$(printf "%x\n" $(ioreg -l|grep -i "DisplayAttributes"|grep -Eo "\"ProductID\"=\d*"|awk -F'=' '{print $NF}'))
names=$(ioreg -l|grep -i "DisplayAttributes"|grep -Eo "\"ProductName\"=\"[^\"]*"|awk -F'="' '{print $NF}')
num=$(echo $vids|awk '{print NF}')
else
edids=$(ioreg -lw0|grep IODisplayEDID|grep -o "<.*>"|sed "s/[<>]//g")
vids=$(printf "%x\n" $(ioreg -l | grep "DisplayVendorID"|awk '{print $NF}'))
pids=$(printf "%x\n" $(ioreg -l | grep "DisplayProductID"|awk '{print $NF}'))
num=$(echo $vids|awk '{print NF}')

for i in $(seq 1 $num);do
vid=$(printf "$vids\n"|sed -n "${i}p")
pid=$(printf "$pids\n"|sed -n "${i}p")
if [ $AS == "1" ];then
name=$(echo "$names"|sed -n ''$i'p')
else
name=$(printf "$edids\n"|sed -n "${i}p"|grep -Eo "fc00.*?0a"|sed "s/^fc00//g"|xxd -r -p)
done

❤ 感谢 Support to detect display info on Apple Silicon Mac

Apple Silicon Mac 获取显示器 Product ID 和 Vendor ID

https://plain-dev.com/dl/get-the-display-product-id-and-vendor-id-on-apple-silicon-mac/

作者

Plain

发布于

2021-09-21

更新于

2022-04-01

许可协议

Your browser is out-of-date!

Update your browser to view this website correctly.&npsb;Update my browser now

×