I’ve got a task to write a script that displays information about which monitors are connected and which interface is used for it. The result of a script execution should look something like this:
ASUS VA24EHF <some device unique id> HDMI
ASUS VA24EHF <some device unique id> DisplayPort
Built-in monitor <some device unique id> eDP
The main problem is that xrandr
contains information about interface but there’s no information about physical device (can’t understand which monitor is used here). Utils like hwinfo
provide exact information about device but doesn’t have one about interface it is connected via.
$ xrandr | grep connected
eDP-1 connected 1368x768+1920+0 (normal left inverted right x axis y axis) 344mm x 194mm
HDMI-1 connected primary 1920x1080+0+0 (normal left inverted right x axis y axis) 527mm x 296mm
DP-1 disconnected (normal left inverted right x axis y axis)
DP-2 disconnected (normal left inverted right x axis y axis)
DP-3 disconnected (normal left inverted right x axis y axis)
HDMI-2 disconnected (normal left inverted right x axis y axis)
$ hwinfo --monitor
34: None 00.0: 10002 LCD Monitor
[Created at monitor.125]
Unique ID: rdCR.BJ+fX804+aD
Parent ID: _Znp.DoEy7b1LcY9
Hardware Class: monitor
Model: "VA24EHF"
Vendor: AUS
Device: eisa 0x2445 "VA24EHF"
Serial ID: "R6LMTF187096"
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: 1280x720@60Hz
Resolution: 1280x960@60Hz
Resolution: 1280x1024@60Hz
Resolution: 1920x1080@60Hz
Size: 527x296 mm
Year of Manufacture: 2022
Week of Manufacture: 51
Detailed Timings #0:
Resolution: 1920x1080
Horizontal: 1920 2008 2052 2200 (+88 +132 +280) +hsync
Vertical: 1080 1084 1089 1125 (+4 +9 +45) +vsync
Frequencies: 148.50 MHz, 67.50 kHz, 60.00 Hz
Driver Info #0:
Max. Resolution: 1920x1080
Vert. Sync Range: 48-100 Hz
Hor. Sync Range: 30-120 kHz
Bandwidth: 148 MHz
Config Status: cfg=new, avail=yes, need=no, active=unknown
Attached to: #28 (VGA compatible controller)
35: None 01.0: 10002 LCD Monitor
[Created at monitor.125]
Unique ID: wkFv.BKbJi+0HUrB
Parent ID: _Znp.DoEy7b1LcY9
Hardware Class: monitor
Model: "BOE CQ LCD Monitor"
Vendor: BOE "BOE CQ"
Device: eisa 0x0747
Resolution: 1920x1080@60Hz
Size: 344x194 mm
Year of Manufacture: 2017
Week of Manufacture: 18
Detailed Timings #0:
Resolution: 1920x1080
Horizontal: 1920 1968 2000 2190 (+48 +80 +270) -hsync
Vertical: 1080 1083 1089 1120 (+3 +9 +40) +vsync
Frequencies: 117.73 MHz, 53.76 kHz, 48.00 Hz
Year of Manufacture: 2017
Week of Manufacture: 18
Detailed Timings #1:
Resolution: 1920x1080
Horizontal: 1920 1968 2000 2230 (+48 +80 +310) -hsync
Vertical: 1080 1083 1089 1140 (+3 +9 +60) +vsync
Frequencies: 152.60 MHz, 68.43 kHz, 60.03 Hz
Config Status: cfg=new, avail=yes, need=no, active=unknown
Attached to: #28 (VGA compatible controller)
Could you please explain how can I get exact information which interface some physical device (monitor) are connected via?