终端命令以显示已连接的显示器/显示器/分辨率? [英] Terminal command to show connected displays/monitors/resolutions?

查看:143
本文介绍了终端命令以显示已连接的显示器/显示器/分辨率?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以通过OS X中的终端获取有关已连接的显示器和显示器及其分辨率的信息?

Is there a way to get the information about connected monitors and displays and their resolutions via the terminal in OS X?

我有一些可以在多台显示器上运行的安装程序,有时安装了GFLW窗口,如果未连接显示器,则该窗口似乎无法打开-我想检查一下显示器是否正确连接,并可能将其转储到计算机上.日志文件,但在未深入研究Obj-C/Cocoa的情况下,我还没有找到编程的方式来实现此目的

I have some installations that run on multiple monitors and sometimes with a GFLW window that seem to not open if a monitor is not attached - I would like to have a check for whether a monitor is attached properly and maybe dump that to a log file, but I haven't found a programmatic way to do that without getting deep into Obj-C/Cocoa

推荐答案

您可以使用system_profiler SPDisplaysDataTypedefaults read /Library/Preferences/com.apple.windowserver.plist:

$ system_profiler SPDisplaysDataType
Graphics/Displays:

    NVIDIA GeForce GT 640M:

      Chipset Model: NVIDIA GeForce GT 640M
      Type: GPU
      Bus: PCIe
      PCIe Lane Width: x16
      VRAM (Total): 512 MB
      Vendor: NVIDIA (0x10de)
      Device ID: 0x0fd8
      Revision ID: 0x00a2
      ROM Revision: 3707
      Displays:
        iMac:
          Display Type: LCD
          Resolution: 1920 x 1080
          Pixel Depth: 32-Bit Color (ARGB8888)
          Main Display: Yes
          Mirror: Off
          Online: Yes
          Built-In: Yes
          Connection Type: DisplayPort
$ defaults read /Library/Preferences/com.apple.windowserver.plist
{
    DisplayResolutionEnabled = 1;
    DisplaySets =     (
                (
                        {
                Active = 1;
                Depth = 4;
                DisplayID = 69731456;
                DisplayProductID = 40978;
                DisplaySerialNumber = 0;
                DisplayVendorID = 1552;
                Height = 1080;
                IODisplayLocation = "IOService:/AppleACPIPlatformExpert/PCI0@0/AppleACPIPCI/P0P2@1/IOPCI2PCIBridge/GFX0@0/NVDA,Display-A@0/NVDA";
                IOFlags = 7;
                LimitsHeight = 1080;
                LimitsOriginX = 0;
                LimitsOriginY = 0;
                LimitsWidth = 1920;
                MirrorID = 0;
                Mirrored = 0;
                Mode =                 {
                    BitsPerPixel = 32;
                    BitsPerSample = 8;
                    DepthFormat = 4;
                    Height = 1080;
                    IODisplayModeID = "-2147479552";
                    IOFlags = 7;
                    Mode = 1;
                    PixelEncoding = "--------RRRRRRRRGGGGGGGGBBBBBBBB";
                    RefreshRate = 0;
                    SamplesPerPixel = 3;
                    UsableForDesktopGUI = 1;
                    Width = 1920;
                    kCGDisplayBytesPerRow = 7680;
                    kCGDisplayHorizontalResolution = 103;
                    kCGDisplayModeIsInterlaced = 0;
                    kCGDisplayModeIsSafeForHardware = 1;
                    kCGDisplayModeIsStretched = 0;
                    kCGDisplayModeIsTelevisionOutput = 0;
                    kCGDisplayModeIsUnavailable = 0;
                    kCGDisplayModeSuitableForUI = 1;
                    kCGDisplayPixelsHigh = 1080;
                    kCGDisplayPixelsWide = 1920;
                    kCGDisplayResolution = 1;
                    kCGDisplayVerticalResolution = 103;
                };
                OriginX = 0;
                OriginY = 0;
                PixelEncoding = "--------RRRRRRRRGGGGGGGGBBBBBBBB";
                Resolution = 1;
                Unit = 0;
                UnmirroredHeight = 1080;
                UnmirroredLimitsHeight = 1080;
                UnmirroredLimitsOriginX = 0;
                UnmirroredLimitsOriginY = 0;
                UnmirroredLimitsWidth = 1920;
                UnmirroredMode =                 {
                    BitsPerPixel = 32;
                    BitsPerSample = 8;
                    DepthFormat = 4;
                    Height = 1080;
                    IODisplayModeID = "-2147479552";
                    IOFlags = 7;
                    Mode = 1;
                    PixelEncoding = "--------RRRRRRRRGGGGGGGGBBBBBBBB";
                    RefreshRate = 0;
                    SamplesPerPixel = 3;
                    UsableForDesktopGUI = 1;
                    Width = 1920;
                    kCGDisplayBytesPerRow = 7680;
                    kCGDisplayHorizontalResolution = 103;
                    kCGDisplayModeIsInterlaced = 0;
                    kCGDisplayModeIsSafeForHardware = 1;
                    kCGDisplayModeIsStretched = 0;
                    kCGDisplayModeIsTelevisionOutput = 0;
                    kCGDisplayModeIsUnavailable = 0;
                    kCGDisplayModeSuitableForUI = 1;
                    kCGDisplayPixelsHigh = 1080;
                    kCGDisplayPixelsWide = 1920;
                    kCGDisplayResolution = 1;
                    kCGDisplayVerticalResolution = 103;
                };
                UnmirroredOriginX = 0;
                UnmirroredOriginY = 0;
                UnmirroredResolution = 1;
                UnmirroredWidth = 1920;
                Width = 1920;
            }
        )
    );
    ForceOldStyleMemoryManagement = 0;
}

这篇关于终端命令以显示已连接的显示器/显示器/分辨率?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆