53

Is there a command that will list displays connected to the computer?

Specifically, I'm looking to find out how my external monitor is being detected by the system when connected by HDMI cable and what it's (not sure of the correct term here) hardware address is (eg. "CRT-0" or "DFP-1").

This is just a general question, but for reference, I'm using:

  • Asus UL30JT laptop - running Ubuntu 12.04 beta and 11.10
  • Asus PA238 23" monitor
  • HDMI 1.4 cable
  • Optimus graphics (Intel + nVidia GeForce 310M) - running with Bumblebee
Erland
  • 731

4 Answers4

62

Try this:

xrandr --query
xrandr --listactivemonitors

This lists the display names and detected available resolutions. You can also reconfigure your displays using xrandr.

Note that this might not work if you're using the ATI drivers; I'm not sure.

opyate
  • 113
  • 1
  • 8
ams
  • 3,089
12

For most machines with the proprietary driver loaded, /usr/lib/nvidia-current/bin/nvidia-xconfig --query-gpu-info --nvidia-cfg-path=/usr/lib/nvidia-current works. Note that I said "with the proprietary driver loaded". For instance, it does not work if the driver is unloaded or nouveau is loaded. Therefore, when using Bumblebee, run optirun /usr/lib/nvidia-current/bin/nvidia-xconfig --query-gpu-info. The --nvidia-cfg-path part is not needed here as optirun sets the correct library path.

See also the discussion on https://github.com/Bumblebee-Project/Bumblebee/issues/21

/var/log/Xorg.0.log (where 0 is the display number) may also contain valuable information about available screens. For Optimus laptops, this log contains only details on the Intel screen, so replace 0 by 8 to find out the log from the X server started by Bumblebee.

Lekensteyn
  • 178,446
5

All other answers only work in specific situations.

@ams's answer requires the $DISPLAY environment variable being set and thus does not work via SSH.

@Lekensteyn's answer obviously only works with nvidia GPUs.

Universal Solution for systems running on X display server

The only infallible solution is to look at the open display unix sockets by the X server, i.e. listing the directory /tmp/.X11-unix/

Ex:

root@host # ls /tmp/.X11-unix/
total 0
srwxrwxrwx 1 root root 0 Apr  2 01:06 X0
srwxrwxrwx 1 root root 0 Apr  2 01:06 X1

This would mean that two displays, respectively called :0 and :1, are connected to the machine.

adamency
  • 162
0

The undermentioned .sh code should perform what you request:

#!/usr/bin/env -S bash
set -x

Updates package selection

sudo apt update && \

Installs the package

sudo apt install -y 'hwinfo' && \

Invokes the installed package

hwinfo --monitor

An example of its output for me is:

72: None 00.0: 10002 LCD Monitor                                
  [Created at monitor.125]
  Unique ID: rdCR.LqF49Z4qR41
  Parent ID: svHJ.Zzd7VOLabX6
  Hardware Class: monitor
  Model: "AOC Q3279WG5B"
  Vendor: AOC "AOC"
  Device: eisa 0x3279 "Q3279WG5B"
  Serial ID: "19441"
  Resolution: 720x400@70Hz
  Resolution: 640x480@60Hz
  Resolution: 640x480@67Hz
  Resolution: 640x480@72Hz
  Resolution: 640x480@75Hz
  Resolution: 800x600@56Hz
  Resolution: 800x600@60Hz
  Resolution: 800x600@72Hz
  Resolution: 800x600@75Hz
  Resolution: 832x624@75Hz
  Resolution: 1024x768@60Hz
  Resolution: 1024x768@70Hz
  Resolution: 1024x768@75Hz
  Resolution: 1280x1024@75Hz
  Resolution: 1920x1080@60Hz
  Resolution: 1280x1024@60Hz
  Resolution: 2560x1440@60Hz
  Size: 725x428 mm
  Year of Manufacture: 2018
  Week of Manufacture: 25
  Detailed Timings #0:
     Resolution: 2560x1440
     Horizontal: 2560 2568 2600 2666 (+8 +40 +106) -hsync
       Vertical: 1440 1443 1448 1481 (+3 +8 +41) +vsync
    Frequencies: 296.00 MHz, 111.03 kHz, 74.97 Hz
  Year of Manufacture: 2018
  Week of Manufacture: 25
  Detailed Timings #1:
     Resolution: 2560x1440
     Horizontal: 2560 2608 2640 2720 (+48 +80 +160) +hsync
       Vertical: 1440 1443 1448 1481 (+3 +8 +41) +vsync
    Frequencies: 241.50 MHz, 88.79 kHz, 59.95 Hz
  Driver Info #0:
    Max. Resolution: 2560x1440
    Vert. Sync Range: 48-76 Hz
    Hor. Sync Range: 114-114 kHz
    Bandwidth: 296 MHz
  Config Status: cfg=new, avail=yes, need=no, active=unknown
  Attached to: #1 (VGA compatible controller)

73: None 01.0: 10002 LCD Monitor [Created at monitor.125] Unique ID: wkFv.08rGJ7kUoc8 Parent ID: svHJ.Zzd7VOLabX6 Hardware Class: monitor Model: "AOC Q3279WG5B" Vendor: AOC "AOC" Device: eisa 0x3279 "Q3279WG5B" Serial ID: "40899" Resolution: 720x400@70Hz Resolution: 640x480@60Hz Resolution: 640x480@67Hz Resolution: 640x480@72Hz Resolution: 640x480@75Hz Resolution: 800x600@56Hz Resolution: 800x600@60Hz Resolution: 800x600@72Hz Resolution: 800x600@75Hz Resolution: 832x624@75Hz Resolution: 1024x768@60Hz Resolution: 1024x768@70Hz Resolution: 1024x768@75Hz Resolution: 1280x1024@75Hz Resolution: 1920x1080@60Hz Resolution: 1280x1024@60Hz Resolution: 2560x1440@60Hz Size: 725x428 mm Year of Manufacture: 2019 Week of Manufacture: 51 Detailed Timings #0: Resolution: 2560x1440 Horizontal: 2560 2568 2600 2666 (+8 +40 +106) -hsync Vertical: 1440 1443 1448 1481 (+3 +8 +41) +vsync Frequencies: 296.00 MHz, 111.03 kHz, 74.97 Hz Year of Manufacture: 2019 Week of Manufacture: 51 Detailed Timings #1: Resolution: 2560x1440 Horizontal: 2560 2608 2640 2720 (+48 +80 +160) +hsync Vertical: 1440 1443 1448 1481 (+3 +8 +41) +vsync Frequencies: 241.50 MHz, 88.79 kHz, 59.95 Hz Driver Info #0: Max. Resolution: 2560x1440 Vert. Sync Range: 48-76 Hz Hor. Sync Range: 114-114 kHz Bandwidth: 296 MHz Config Status: cfg=new, avail=yes, need=no, active=unknown Attached to: #1 (VGA compatible controller)

Luckily, this is independent of the display server (and compositor) so this functions on Wayland too.