web-dev-qa-db-ja.com

接続されたディスプレイ/モニター/解像度を表示するターミナルコマンド?

OS Xの端末を介して、接続されているモニターとディスプレイ、およびそれらの解像度に関する情報を取得する方法はありますか?

複数のモニターで実行され、モニターが接続されていない場合はGFLWウィンドウが開かないように見えるインストールがいくつかあります-モニターが正しく接続されているかどうかを確認し、ログファイルにダンプしたいのですが、しかし、Obj-C/Cocoaに深く踏み込むことなくそれを行うためのプログラム的な方法を見つけていません。

12
laserpilot

system_profiler SPDisplaysDataTypeまたはdefaults 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;
}
18
Lri