Как узнать название дисплея linux

Как узнать текущее разрешение монитора или имя монитора (LVDS, VGA1 и т. Д.)

Я хотел бы получить разрешение текущего монитора (экран, с которого я запускаю скрипт) или название экрана (LVDS, VGA1 и т.д.). Если я не могу получить разрешение, а только имя монитора, я могу получить вывод «xrandr -q» для получения текущего разрешения. Заранее спасибо.

3 ответа 3

$ xrandr | grep -w connected | awk -F'[ \+]' '' VGA-0 1440x900 1600 DP-3 1600x900 0 
$ xwininfo -id $(xdotool getactivewindow) | grep Absolute Absolute upper-left X: 1927 Absolute upper-left Y: 70 

Таким образом, комбинируя эти два параметра, вы сможете получить разрешение текущего экрана:

#!/usr/bin/env bash ## Get screen info screen1=($(xrandr | grep -w connected | awk -F'[ +]' '' | head -n 1)) screen2=($(xrandr | grep -w connected | awk -F'[ +]' '' | tail -n 1)) ## Figure out which screen is to the right of which if [ $ -eq 0 ] then right=($); left=($); else right=($); left=($); fi ## Get window position pos=$(xwininfo -id $(xdotool getactivewindow) | grep "Absolute upper-left X" | awk '') ## Which screen is this window displayed in? If $pos ## is greater than the offset of the rightmost screen, ## then the window is on the right hand one if [ "$pos" -gt "$" ] then echo "$ : $" else echo "$ : $" fi 

Скрипт напечатает имя и разрешение текущего экрана.

Я изменил (превосходное) решение @ terdon, чтобы оно работало с любым количеством мониторов, расположенных горизонтально и / или вертикально, и изменил способ захвата смещений из xrandr (он не работал на моей установке, возможно, из-за изменение выходного формата xrandr).

#!/usr/bin/env bash OFFSET_RE="\+([-0-9]+)\+([-0-9]+)" # Get the window position pos=($(xwininfo -id $(xdotool getactivewindow) | sed -nr "s/^.*geometry .*$OFFSET_RE.*$/\1 \2/p")) # Loop through each screen and compare the offset with the window # coordinates. while read name width height xoff yoff do if [ "$" -ge "$xoff" \ -a "$" -ge "$yoff" \ -a "$" -lt "$(($xoff+$width))" \ -a "$" -lt "$(($yoff+$height))" ] then monitor=$name fi done < <(xrandr | grep -w connected | sed -r "s/^([^ ]*).*\b([-0-9]+)x([-0-9]+)$OFFSET_RE.*$/\1 \2 \3 \4 \5/" | sort -nk4,5) # If we found a monitor, echo it out, otherwise print an error. if [ ! -z "$monitor" ] then echo $monitor exit 0 else echo "Couldn't find any monitor for the current window." >&2 exit 1 fi 

Стоит также отметить, что xdotool может выводить экран, на котором находится окно, но, если вы используете Xinerama, который заставляет все ваши мониторы отображаться как один большой экран, он будет выводить только 0.

По какой-то причине я не смог получить ответ @ adam-bowen, работающий с диспетчером окон, хотя некоторые незначительные правки для использования координат мыши работали.

#!/usr/bin/env bash # # Print's the current screen index (zero based). # # Modified from: # https://superuser.com/a/992924/240907 OFFSET_RE="\+([-0-9]+)\+([-0-9]+)" # Get the window position eval "$(xdotool getmouselocation --shell)" # Loop through each screen and compare the offset with the window # coordinates. monitor_index=0 while read name width height xoff yoff do if [ "$" -ge "$xoff" \ -a "$" -ge "$yoff" \ -a "$" -lt "$(($xoff+$width))" \ -a "$" -lt "$(($yoff+$height))" ] then monitor=$name break fi ((monitor_index++)) done < <(xrandr | grep -w connected | sed -r "s/^([^ ]*).*\b([-0-9]+)x([-0-9]+)$OFFSET_RE.*$/\1 \2 \3 \4 \5/" | sort -nk4,5) # If we found a monitor, echo it out, otherwise print an error. if [ ! -z "$monitor" ] then # echo $monitor echo $monitor_index exit 0 else echo "Couldn't find any monitor for the current window." >&2 exit 1 fi 

Источник

Get monitor make and model and other info in human readable form

I have extracted the shorthand version of the current monitor attached to the computer.
Here is an example: vendor «VSC», prod id «18500» In Ubuntu’s Monitor Preferences, it is identified as Viewsonic Corporation 16″ . How can I extract this human readable form? . and also, how can I determine if a monitor is a CRT or an LCD ? (this is actually what got me started on this quest) The EDID format can be found on Wikipedia: Extended display identification data
Here is the code used to get the EDID Vendor and Product id

edid=$(xrandr -q --verbose | sed -n '/^[[:space:]]\+00ffffffffffff00/,/[^a-fA-F0-9[:space:]]/< /[^a-fA-F0-9[:space:]]/d s/[[:space:]]\+//g; p>') nibble=() vend=$(for i in ;do printf "%s" $))]> done) vend="$(for i in 1 6 11 ;do printf \\x$(printf %x $((2#$ +64))) done)" prod=$((16#$$)) printf "monitor: vendor \"%s\", prod id \"%s\"\n" "$" "$prod" 
Screen 0: minimum 320 x 200, current 1280 x 960, maximum 8192 x 8192 VGA1 connected 1280x960+0+0 (0x47) normal (normal left inverted right x axis y axis) 320mm x 240mm Identifier: 0x41 Timestamp: 26386 Subpixel: unknown Clones: CRTC: 0 CRTCs: 0 1 Transform: 1.000000 0.000000 0.000000 0.000000 1.000000 0.000000 0.000000 0.000000 1.000000 filter: EDID: 00ffffffffffff005a63444809000000 15090101682018b1e84f22a157479925 0f484ffffe00315945596159714f8140 818001010101000000ff004848393231 30303030390a2020000000fd0032781e 46ff000a202020202020000000fc0056 696577536f6e696320453737000000fc 00312d320a2020202020202020200084 1280x1024 (0x46) 108.0MHz +HSync +VSync h: width 1280 start 1328 end 1440 total 1688 skew 0 clock 64.0KHz v: height 1024 start 1025 end 1028 total 1066 clock 60.0Hz 1280x960 (0x47) . . . etc 

6 Answers 6

In Ubuntu’s Monitor Preferences, it is identified as Viewsonic Corporation 16″. How can I extract this human readable form?

That human readable form («Viewsonic Corporation») doesn’t come directly from your EDID: Ubuntu uses gnome libraries underneath. libgnome-desktop decodes the edid and via pnp.ids converts the three-letter vendor ID («VSC» in your particular case) into a «pretty name for the display.
On my system

grep VSC /usr/share/hwdata/pnp.ids 
VSC ViewSonic Corporation 

That aside, additional information can be extracted from the EDID, namely from the descriptor blocks. From the same wikipedia link:

  • Monitor range limits (required)
  • ASCII text (monitor name (required), monitor serial number or unstructured text)
  • 6 Additional standard timing information blocks
  • Colour point data
  • 0xFF: Monitor serial number (text)
  • 0xFE: Unspecified text (text)
  • 0xFD: Monitor range limits. 6- or 13-byte binary descriptor.
  • 0xFC: Monitor name (text)
  • 0xFB: Additional white point data. 2× 5-byte descriptors, padded with 0A 20 20.
  • 0xFA: Additional standard timing identifiers. 6× 2-byte descriptors, padded with 0A.

In your EDID you have 0xFF (serial number) in descriptor 1 (bytes 54-71):

00 ff 00 48 48 39 32 31 30 30 30 30 39 0a 20 20 00 00 

and you have 0xFC (monitor name) in descriptor 3 (bytes 90–107) and 4 (bytes 108–125):

 00 fc 00 56 69 65 77 53 6f 6e 69 63 20 45 37 37 00 00 00 fc 00 31 2d 32 0a 20 20 20 20 20 20 20 20 20 00 84 

so it’s only a matter of extracting the information from there, e.g. descriptor 3:

56 69 65 77 53 6f 6e 69 63 20 45 37 37 >> Viewsonic E77

Finally, I have no idea how to determine (in linux) if a monitor is LCD or CRT. I don’t know of any library that implements such function (like this one from MS).

Something like this should work better (all others answers didn’t work 100% here):

for file in `ls -1 /sys/class/drm/*/edid`; do text=$(tr -d '\0' <"$file"); if [ -n "$text" ]; then edid-decode "$file" | grep -e Manufacturer: -e Product; sleep 0.0001; fi done 

I tested here with 2 monitors. My primary is a builtin laptop monitor and the secondary is a DELL 25". This was the output:

Manufacturer: DELL Model 53359 Serial Number 809781068 Display Product Serial Number: YKFWP5790DGL Display Product Name: DELL U2515H Manufacturer: LGD Model 1133 Serial Number 0 

You must have installed the edid-decode in your distro. My setup is DELL Latitude e5450 with Ubuntu 20.04.

Does not work if nvidia binary driver is in use, because there are no files /sys/class/drm/*/edid then. Related bug report

The following tool can be helpful for decoding edid info: http://cgit.freedesktop.org/xorg/app/edid-decode

Some window managers provide commands for listing output details. This one works if you are running swaywm :

It generates the following output

Output eDP-1 'Unknown 0x408D 0x00000000' Current mode: 1920x1080 @ 60.049000 Hz Position: 0,0 Scale factor: 1.000000 Scale filter: nearest Subpixel hinting: unknown Transform: normal Workspace: 10 Max render time: off Adaptive sync: disabled Available modes: 640x480 @ 60.049000 Hz 800x600 @ 60.049000 Hz 1024x768 @ 60.049000 Hz 1280x720 @ 60.049000 Hz 1280x800 @ 60.049000 Hz 1440x900 @ 60.049000 Hz 1280x1024 @ 60.049000 Hz 1680x1050 @ 60.049000 Hz 1920x1080 @ 60.049000 Hz Output HDMI-A-1 'Samsung Electric Company C24F390 SRNABC123' (focused) Current mode: 1920x1080 @ 60.000000 Hz Position: 1920,0 Scale factor: 1.000000 Scale filter: nearest Subpixel hinting: unknown Transform: normal Workspace: 1 Max render time: off Adaptive sync: disabled Available modes: 720x400 @ 70.082001 Hz 640x480 @ 59.939999 Hz 640x480 @ 60.000000 Hz 640x480 @ 66.667000 Hz 640x480 @ 72.808998 Hz 720x480 @ 59.939999 Hz 720x480 @ 59.939999 Hz 720x480 @ 60.000000 Hz 720x480 @ 60.000000 Hz 720x576 @ 50.000000 Hz 720x576 @ 50.000000 Hz 800x600 @ 56.250000 Hz 800x600 @ 60.317001 Hz 800x600 @ 72.188004 Hz 1024x768 @ 60.004002 Hz 1024x768 @ 70.069000 Hz 1280x720 @ 50.000000 Hz 1280x720 @ 50.000000 Hz 1280x720 @ 59.939999 Hz 1280x720 @ 60.000000 Hz 1280x720 @ 60.000000 Hz 1280x800 @ 59.910000 Hz 1440x900 @ 59.901001 Hz 1280x1024 @ 60.020000 Hz 1600x900 @ 60.000000 Hz 1680x1050 @ 59.882999 Hz 1920x1080 @ 50.000000 Hz 1920x1080 @ 59.939999 Hz 1920x1080 @ 60.000000 Hz 1920x1080 @ 60.000000 Hz 

Источник

How do you find out a laptop screen panel manufacturer / model with Linux? (Samsung, LG, Chi Mei, etc)

How do you find out a laptop screen panel manufacturer / model with Linux? (Samsung, LG, Chi Mei, etc) + model number? I've tried using this command "lshw" in Ubuntu, but it doesn't seem to have the panel listed in there. Thank you.

8 Answers 8

Use any utility that shows the EDID information. One place to look for this information is in /var/log/Xorg.0.log

Thanks fpmurphy, That log file did have a reference to the panel in there. Interestingly, a Windows program called HWINFO64 seems to give a much more detailed description of the monitor "AU Optronics [model number], etc" but the Linux Xorg.0.log file has "AUO". I wish I could find a similar program to HWINFO64 for Linux.. Still marking your answer as accepted since I can at least use it as a clue and it does indicate the brand. Thanks!

My info did not show up in XOrg.log. But I figured out that I could get the info from the DRM (Direct Rendering Manager) subcomponent of the linux kernel, which is exposed in sysfs. So I did the following:

root@dark:~# ls /sys/class/drm/ card0 card0-DP-2 card0-eDP-1 card0-HDMI-A-2 card0-VGA-1 version card0-DP-1 card0-DP-3 card0-HDMI-A-1 card0-HDMI-A-3 controlD64 

You can figure out which screens are active by doing some probing here:

root@dark:/sys/class/drm# cat card0-HDMI-A-2/enabled enabled root@dark:/sys/class/drm# cat card0-HDMI-A-3/enabled disabled 

I then parsed the EDID info from the screens I was interested in as follows:

root@dark:/sys/class/drm# cat card0-HDMI-A-1/edid | edid-decode Extracted contents: header: 00 ff ff ff ff ff ff 00 serial number: 09 d1 0a 78 45 54 00 00 16 12 version: 01 03 basic params: 80 34 20 78 2e chroma info: c5 c4 a3 57 4a 9c 23 12 4f 52 established: a5 6b 80 standard: 71 00 81 00 95 00 81 80 b3 00 a9 40 d1 00 01 01 descriptor 1: 28 3c 80 a0 70 b0 23 40 30 20 36 00 07 44 21 00 00 1a descriptor 2: 00 00 00 ff 00 56 35 38 30 30 34 35 35 5a 4c 30 0a 20 descriptor 3: 00 00 00 fd 00 32 55 1f 5e 11 00 0a 20 20 20 20 20 20 descriptor 4: 00 00 00 fc 00 42 65 6e 51 20 47 32 34 30 30 57 0a 20 extensions: 01 checksum: e5 Manufacturer: BNQ Model 780a Serial Number 21573 Made week 22 of 2008 EDID version: 1.3 Digital display Maximum image size: 52 cm x 32 cm Gamma: 2.20 DPMS levels: Off Supported color formats: RGB 4:4:4, YCrCb 4:2:2 Default (sRGB) color space is primary color space First detailed timing is preferred timing Established timings supported: 720x400@70Hz 640x480@60Hz 640x480@75Hz 800x600@60Hz 800x600@75Hz 832x624@75Hz 1024x768@60Hz 1024x768@75Hz 1280x1024@75Hz 1152x870@75Hz Standard timings supported: 1152x720@60Hz 1280x800@60Hz 1440x900@60Hz 1280x1024@60Hz 1680x1050@60Hz 1600x1200@60Hz 1920x1200@60Hz Detailed mode: Clock 154.000 MHz, 519 mm x 324 mm 1920 1968 2000 2080 hborder 0 1200 1203 1209 1235 vborder 0 +hsync -vsync Serial number: V5800455ZL0 Monitor ranges: 50-85HZ vertical, 31-94kHz horizontal, max dotclock 170MHz Monitor name: BenQ G2400W Has 1 extension blocks Checksum: 0xe5 CEA extension block Extension version: 3 22 bytes of CEA data Video data block VIC 04 VIC 16 (native) VIC 03 VIC 01 VIC 05 (native) Vendor-specific data block, OUI 000c03 (HDMI) Source physical address 1.0.0.0 Speaker allocation data block Audio data block Underscans PC formats by default Basic audio support Supports YCbCr 4:4:4 Supports YCbCr 4:2:2 1 native detailed modes Detailed mode: Clock 74.250 MHz, 708 mm x 398 mm 1280 1390 1430 1650 hborder 0 720 725 730 750 vborder 0 +hsync +vsync Detailed mode: Clock 74.250 MHz, 708 mm x 398 mm 1920 2008 2052 2200 hborder 0 540 542 547 562 vborder 0 +hsync +vsync interlaced Detailed mode: Clock 27.000 MHz, 708 mm x 398 mm 720 736 798 858 hborder 0 480 489 495 525 vborder 0 -hsync -vsync Detailed mode: Clock 148.500 MHz, 708 mm x 398 mm 1920 2008 2052 2200 hborder 0 1080 1084 1089 1125 vborder 0 +hsync +vsync analog composite Detailed mode: Clock 25.180 MHz, 530 mm x 398 mm 640 648 744 800 hborder 8 480 482 484 525 vborder 8 -hsync -vsync Checksum: 0x2c 

Источник

Читайте также:  Linux command get directory
Оцените статью
Adblock
detector