How to check if a display is built-in display on Mac OSX?

1.3k views Asked by At

In System Information (or the command line equivalent: system_profiler) we can check if a display is built-in:

Displays:
Color LCD:
Display Type: LCD
Resolution: 1680 x 1050
Pixel Depth: 32-Bit Color (ARGB8888)
Main Display: Yes
Mirror: Off
Online: Yes
Built-In: Yes

What API should I use to check the same information? The app needs to disable playback when external display is connected. Note that HDCP isn't available on Mac therefore disabling it is the only way. (DRM stuff, which I hate).

1

There are 1 answers

0
Paul Sweatte On

Use the CGDisplayIsBuiltin(_:) method:

Returns a Boolean value indicating whether a display is built-in, such as the internal display in portable systems.

which is part of Quartz Display Services:

Quartz Display Services includes accessor functions that report current properties of the display hardware, properties that are also found in the current display mode. Because these functions do not rely on information from the current display mode, they provide the most accurate information available about the display (display mode properties are subject to change by the device driver).

References