Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to query X11 display resolution?

Tags:

linux

x11

It seems like an simple problem, but I can't find the answer: How do you query (via X11) what monitors exist and their resolutions?

like image 813
dicroce Avatar asked Dec 01 '09 23:12

dicroce


People also ask

How do I find my screen resolution Linux?

To use the xdpyinfo utility command to retrieve the Linux desktop screen resolution, we will first execute the xdpyinfo command, pipe it to a grep command that will retrieve the dimensions aspect of its output, and finally pipe the values of the dimension to the awk command for display as Linux terminal output.

How do I find my screen resolution in CMD?

Find your screen resolution by running a command in Command Prompt or PowerShell (all Windows versions) If you like using the Command Prompt or PowerShell, you can use the command wmic path Win32_VideoController get CurrentHorizontalResolution,CurrentVerticalResolution to find out what resolution your screen has.

How do I find my screen resolution in Linux Mint?

Press the Super key, then type “Display” and hit enter. The “Resolution” you pick should be the native resolution of your monitor and will generally be the recommended setting.


2 Answers

Check out display macros and screen macros from the Xlib manual.

Specifically:

  • From the first link: ScreenCount(), ScreenOfDisplay()
  • From the second link: WidthOfScreen(), HeightOfScreen()
like image 171
asveikau Avatar answered Sep 30 '22 21:09

asveikau


This might be helpfull for cli and scripting

xwininfo -root

But xRandR might be more accurate, especially, when there is multiple monitor environment:

xrandr
like image 42
Grzegorz Wierzowiecki Avatar answered Sep 30 '22 21:09

Grzegorz Wierzowiecki