Terminal command to display connected displays / monitors / resolutions?

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

I have several settings that run on multiple monitors, and sometimes with a GFLW window, which do not seem to open if the monitor is not connected. I would like to check if the monitor is connected correctly and possibly dump it on log, but I did not find a programmatic way to do this without delving into Obj-C / Cocoa

+6
source share
1 answer

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; } 
+7
source

Source: https://habr.com/ru/post/958487/


All Articles