Terminal command to show connected displays/monitors/resolutions?

后端 未结 2 1344
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-02-01 23:26

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

I have some installations that run on multip

相关标签:
2条回答
  • 2021-02-02 00:12

    You can use system_profiler SPDisplaysDataType or 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;
    }
    
    0 讨论(0)
  • 2021-02-02 00:15

    You can also use a command-line tool called cscreen:

    # install homebrew if you don't have it already
    /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
    
    # install cscreen
    brew install --cask cscreen
    
    # list displays
    cscreen -l
    

    output:

    DisplayID  Index     Depth     Width     Height  Refresh
           1       1        32      1440        900    60
           2       2        32      1920       1080    60
    use -h to display all usage options
    

    Note:

    • The first time you try to open the cscreen the os will not allow it because it isn't signed.
    • You have to go to Security & Privacy in System Preferences and allow it.

    Homebrew package search

    0 讨论(0)
提交回复
热议问题