1

macOS 10.15+ provides NSScreen.localizedName, which provides a user-facing name for the screen, such as "Built-in Retina Display" or "Встроенный дисплей Retina" (if local language is Russian).

However, I need to support macOS older than 10.15, and it's not clear what the fallback should be.

I see this question, "How to Get the Display Name with the Display ID in Mac OS X?". However, all answers use CGDisplayIOServicePort, which is unavailable in macOS >10.9.

I also see this question, "CGDisplayIOServicePort is deprecated in OS X >= 10.9, how to replace?". However, all answers depend on GLFW, an enormous library that I clearly don't want to include just to get the display name.

(EDIT) I also found this shim, "get display name from NSScreen", but it doesn't work properly - for instance, my "Built-in Retina Display" gets the odd name "Color LCD", and it doesn't find a io_service_t for my Sidecar iPad screen.

jameshfisher
  • 34,029
  • 31
  • 121
  • 167

1 Answers1

0

The screen's actual name is "Color LCD", but the user-friendly localizedName (and the one System Prefs shows in older OS versions) has an extra check to detect that it's a laptop's internal display.