I am looking for a consistant way of getting the name of the built-in monitor in a laptop. To be exact, I am looking for the name of the monitor that will be turned off when the lid is closed. I was just wondering if there is a way without any hypothesis on the name (not listing every existing names...).

At first, it seems that the only difference is the way that the monitor is plugged to the motherboard, so names must be a relevent clue but I was wondering if it was possible without that.

For example, I was looking at how logind was able to differenciate HandleSwitchLid and HandleSwitchLidDocked, but I did not find anything very useful as sometimes sources are not very easy to understand


There's no universal and guaranteed reliable way to tell if a screen is internal.

There's simply no standardized hardware flag that would tell you "this screen is physically built into the same case as the rest of the computer". So you need to guess, and the type of the interface is a good source of some hints, just because there aren't any video interfaces that would be commonly used both internally and externally.

Your idea to look at logind is reasonable. The important piece is manager_count_external_displays in logind-core.c, which uses this list of "likely external" interfaces:

"VGA-", "DVI-I-", "DVI-D-", "DVI-A-"
"Composite-", "SVIDEO-", "Component-",
"DIN-", "DP-", "HDMI-A-", "HDMI-B-", "TV-"

As mentioned in an accompanying comment, they prefer to possibly miss some external displays than to mistake an internal one for external (and block suspending the system for no reason). If you'd rather do it the other way, you probably need to look just for eDP and LVDS as the "likely internal" interfaces.


You might be able to use xrandr to give you the output you need. For instance, xrandr --query on my machine shows the adapters (the first one on my laptop is eDP1, and xrandr --listmonitors shows the monitor names as I'd see them in my Monitors and screen gui panel.

Also, from the output if you just wanted to exclude externals you could do something like this:

xrandr --query | grep ' connected' | grep -vEi '(hdmi|vga|virtual)'


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.