Посмотреть разрешение экрана линукс

Как узнать разрешение экрана из сценария оболочки?

Команда xdpyinfo отображает различную информацию о вашем X-сервере. Он много чего пишет в стандартный вывод, но нам нужна только строка, начинающаяся со слова dimensions , поэтому мы используем grep . Наконец мы используем sed для очистки результата.

xdpyinfo | grep dimensions даст вам общее разрешение, если у вас есть несколько мониторов, это будет сумма всех их. xrandr —current предоставит вам разрешение для каждого монитора. Я использую этот фрагмент, чтобы найти максимально возможное разрешение для rDesktop, не переходя на полный экран:

Xaxis=$(xrandr --current | grep '*' | uniq | awk '' | cut -d 'x' -f1) Yaxis=$(xrandr --current | grep '*' | uniq | awk '' | cut -d 'x' -f2) 
rdesktop -u $User -P -z -5 -g $MaxRes $Host & 
avconv -f x11grab -r 15 -s `xrandr --current | grep '*' | uniq | awk ''` -i :0.0 -c:v libx264 ./output.mp4 

Вы можете использовать команду xrandr -q . Из этого вы можете создать сценарий оболочки, если это необходимо. Для получения дополнительной информации о команде перейдите сюда или введите man xrandr

############################################# ## I use this with a Video Recording Program. # window size --root option - information on the screen's root window echo $(xwininfo -root | grep 'geometry' | awk '') # output(s): 1024x768+0+0 # height x width + x + y positions. ###################### ## Reference Manual ## man xwininfo

Созданы две возможные альтернативы, объединяющие ответы @ user31752 и @ eliezer-e-vargas Более простое регулярное выражение:

$ xrandr --current | sed -n 's/.* connected \(1*\)x\(8*\)+.*/\1x\2/p' 1440x900 
$ xrandr --current | grep ' connected ' | cut -d ' ' -f 3 | cut -d '+' -f 1 1440x900 

Использование grep ‘*’ | uniq от @ eliezer-e-vargas получает другую строку (например, «1440×900 59.90 *+ 59.89») выхода xrandr, тогда как grep ‘connected’ получает простую (например, LVDS1 подключена 1440×900+ 0+ 0 .. . «). Использование regex @ user31752 приятно, поэтому строка, которую я использую, нуждается в более простом регулярном выражении или может быть заменена более простой командой cut. Пример вывода xrandr

$ xrandr --current Screen 0: minimum 320 x 200, current 1440 x 900, maximum 8192 x 8192 LVDS1 connected 1440x900+0+0 (normal left inverted right x axis y axis) 331mm x 207mm 1440x900 59.90*+ 59.89 1360x768 59.80 59.96 1152x864 60.00 1024x768 60.00 800x600 60.32 56.25 640x480 59.94 VGA1 disconnected (normal left inverted right x axis y axis) HDMI1 disconnected (normal left inverted right x axis y axis) DP1 disconnected (normal left inverted right x axis y axis) 

Источник

Читайте также:  Tor браузер на linux

Display monitor info via command line

Is there a way to query monitor information from command line? For example, get monitor model, similar to e.g. what lspci does for graphic card info, or whether it’s currently on or off, things like that. If possible, what kinds of basic information such as the above can be easily gathered? For example, is it possible to determine if monitor is in portrait or landscape position? Or if it has built-in speakers or not? Command line is the preference, but if there’s a GUI method, I’d like to hear about it, too.

02:00.0 VGA compatible controller: Advanced Micro Devices [AMD] nee ATI Madison [Mobility Radeon HD 5650/5750 / 6550M]

8 Answers 8

Yes there is, read-edid hardware information-gathering tool for VESA PnP monitors. This tool have two commands: get-edid and parse-edid : tools to retrieve and interpret monitor specifications using the VESA VBE DDC protocol. EDID (Extended Display Identification Data) is a metadata format for display devices to describe their capabilities to a video source.

sudo apt-get install read-edid 

Thanks thom — can you clarify how can I get monitor model using get-edid / parse-edid ? When I ran the above, it did not print anything (not even in Section «Monitor») that would be similar to my monitor manufacturer / model. If that’s OK with you, can you paste what you get on your machine and the monitor model you have, just for comparison?

Identifier «\QX:2d40» VendorName «\QX» ModelName «\QX:2d40» I have to say that the EDID of my monitor is buggy as hell. So that is not really representative 🙂

Thanks thom — looks similar on my end: ModelName «LGD:8902» , so looks like it is representative after all 🙂 Also, it only displays my laptop monitor, but not the external one.

A lot of EDIDs are buggy. Manufacturers don’t care and driverdevelopers are doing mostly workarounds. Best info is coming from closed source videodrivers. I extract it like this: grep «Display» /var/log/Xorg.0.log |tail -1 for extensive info I use grep «NVIDIA(GPU-0)» /var/log/Xorg.0.log

Case where get-edid does not show all monitors

$ lshw -c display *-display description: VGA compatible controller product: 3rd Gen Core processor Graphics Controller vendor: Intel Corporation physical id: 2 bus info: pci@0000:00:02.0 version: 09 width: 64 bits clock: 33MHz capabilities: vga_controller bus_master cap_list rom configuration: driver=i915 latency=0 resources: irq:27 memory:f6400000-f67fffff memory:e0000000-efffffff ioport:f000(size=64) 

get-edid shows only the external monitor which is plugged to VGA port.

 sudo apt-get install read-edid 
 ls /sys/class/drm/*/edid | xargs -i<> sh -c "echo <>; parse-edid < <>" 

Method 2, reading the edid files from sysfs worked for me, thanks! It seems like read-edid probably needs to be updated.

$ grep "NVIDIA(GPU-0)" /var/log/Xorg.0.log |head -17| cut -d\: -f2 Display (Samsung SA300/SA350 (DFP-0)) does not support NVIDIA 3D Vision stereo. The EDID for Samsung SA300/SA350 (DFP-0) contradicts itself mode "1920x1080" is specified in the EDID; however, the EDID's valid VertRefresh range (56.000-75.000 Hz) would exclude this mode's VertRefresh (50.0 Hz); ignoring VertRefresh check for mode "1920x1080". The EDID for Samsung SA300/SA350 (DFP-0) contradicts itself mode "1280x720" is specified in the EDID; however, the EDID's valid VertRefresh range (56.000-75.000 Hz) would exclude this mode's VertRefresh (50.0 Hz); ignoring VertRefresh check for mode "1280x720". The EDID for Samsung SA300/SA350 (DFP-0) contradicts itself mode "720x576" is specified in the EDID; however, the EDID's valid VertRefresh range (56.000-75.000 Hz) would exclude this mode's VertRefresh (50.0 Hz); ignoring VertRefresh check for mode "720x576". 

first line is the command. Note that this is not de official way to get vendor/model info from the monitor (but tragically it is often the only way), also it is GPU-vendor dependent.

Читайте также:  Laptops linux operating system

@BorisVerkhovskiy Refer to the Arch wiki for more info. And of course this specific command requires an NVIDIA GPU.

(I used the program once when I was playing with dual monitor setup on Archlinux .)

You can find it in the x11-server-utils package. That package contains other stuff to play with like:

  • iceauth, a tool for manipulating ICE protocol authorization records;
  • rgb;
  • sessreg, a simple program for managing utmp/wtmp entries;
  • xcmsdb, a device color characteristic utility for the X Color Management System;
  • xgamma, a tool for querying and setting a monitor’s gamma correction;
  • xhost, a very dangerous program that you should never use;
  • xmodmap, a utility for modifying keymaps and pointer button mappings in X;
  • xrandr, a command-line interface to the RandR extension;
  • xrdb, a tool to manage the X server resource database;
  • xrefresh, a tool that forces a redraw of the X screen;
  • xset, a tool for setting miscellaneous X server parameters;
  • xsetmode and xsetpointer, tools for handling X Input devices;
  • xsetroot, a tool for tailoring the appearance of the root window;
  • xstdcmap, a utility to selectively define standard colormap properties;
  • xvidtune, a tool for customizing X server modelines for your monitor. (information found in synaptic package manager)

This gives you all the information you need:

dbus-send —session —print-reply —dest=org.gnome.Mutter.DisplayConfig /org/gnome/Mutter/DisplayConfig org.gnome.Mutter.DisplayConfig.GetCurrentState

xrandr , xrandr —prop and xrandr —verbose will give you some information with different level of detail.

Manufacturer-provided information can be found in the EDID format.

To get and decode EDID, first check xrandr output to find out the used interface (e.g. eDP-1 ) and apt install edid-decode , then:

Example output you can find here. Replace eDP-1 with your interface if needed.

Читайте также:  Linux mint сменить тему

Alternatively, xrandr —prop outputs EDID in hex format that you can feed to this online EDID decoder.

I don’t recommend using read-edid package because I had negative experiences with it (version 3.0.2 ). In my case, get-edid outputs additional characters after the end that lead to a warning from edid-decode and parse-edid outputs random garbage in ModelName and Identifier fields.

This worked for me on Ubuntu 18.04.
The monitor is connected using HDMI:

grep -i "monitor name" /var/log/syslog 

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 

Источник

Оцените статью
Adblock
detector