How to get current X screen resolution


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers How to get current X screen resolution
# 1  
Old 12-24-2009
How to get current X screen resolution

Hi,

I need to get the current X*Y resolution of X in a shell script. xrandr -q gives me a line like this:
Screen 0: minimum 320 x 200, current 1600 x 1200, maximum 3080 x 1600

How can I extract the X and Y current resolution values? sed, awk, cut or any other console solution is welcomed.

Thanks
# 2  
Old 12-24-2009
The output from xdpyinfo(1) also includes amongst many other things the line:
Code:
dimensions:    1280x800 pixels (301x192 millimeters)

that provides what you want, as long as you have only 1 screen.

But using xrandr(1) the following would do the trick:
Code:
$ cat ./xrandr_test.sh
LINE=`xrandr -q | grep Screen`
echo LINE = ${LINE}
WIDTH=`echo ${LINE} | awk '{ print $8 }'`
echo WIDTH = ${WIDTH}
HEIGHT=`echo ${LINE} | awk '{ print $10 }' | awk -F"," '{ print $1 }'`
echo HEIGHT = ${HEIGHT}
$ ./xrandr_test.sh
LINE = Screen 0: minimum 320 x 240, current 1280 x 800, maximum 1280 x 800
WIDTH = 1280
HEIGHT = 800
$


Last edited by TonyFullerMalv; 12-24-2009 at 03:24 PM..
# 3  
Old 12-25-2009
MySQL

Thank you. This solves my problem.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Solaris

Screen Resolution

Hi all. I have a very peculiar problem in Solaris 10. The output of the m64config -prconf command with regards the Card Adapter is the following. Card possible resolutions: 720x400x85, 640x480x60, 640x480x72, 640x480x75 800x600x56, 800x600x60, 800x600x72, 800x600x75, 1024x768x60 ... (0 Replies)
Discussion started by: lynxman
0 Replies

2. Linux

How to change screen Resolution?

Dear all I install Cent OS 5.5 ( Linux OS), with bshell and also Windows OS on the my laptop (ASUA) maximum screen resolution in Windows OS is 1024*760 but in Cent OS 5.5 is 800 *600, I have a program that is necessary to install on Cent OS and I have problem with other Linux distributions... (2 Replies)
Discussion started by: mkhorami76
2 Replies

3. UNIX for Dummies Questions & Answers

Changing the screen resolution

I have installed several flavors of Linux and FreeBSD onto my machine. Now when I want to change my screen resolution, it only has one option which is 800x600. Is there a way to change that to a bigger resolution? And if there is, what file do I have to edit and what text editor do I have to use?... (2 Replies)
Discussion started by: figaro
2 Replies

4. Red Hat

Screen resolution before and after login

system: Fedora14 on vmware the login screen resolution is 1024*768, but after login the resolution is 800*600. I want to set the login screen resolution as 800*600 too. How to do this? thanks! (2 Replies)
Discussion started by: vistastar
2 Replies

5. Solaris

screen resolution

how to change screen resolution in CDE prompt (2 Replies)
Discussion started by: tirupathi
2 Replies

6. Solaris

Screen Saver Resolution

I am using sun solaris machine i have given the specs of that machine given below Name of athe Platform : SUNW,Ultra-5_10 Machiene hardware :sun4u Processor Type :sparc Operating system : solaris 10 Monitory TYpe : SAMSUNG Sync Master... (2 Replies)
Discussion started by: ambavaram
2 Replies

7. Solaris

Someone's got to know... Screen resolution question.

Hi all, Someone please help, I have a machine running Sun Solaris 5.8. X used to run fine, not it can't start. (possible user intervention) It looks to be trying to run at 1280x1024. I don't think the hardware will support it, it seems high. Anyways, how from the commandline, via ssh, can I... (4 Replies)
Discussion started by: komputersman
4 Replies

8. UNIX for Dummies Questions & Answers

Changing my Screen Resolution (Not in X)

I have no graphical environment, no X, just a shell... but its WAY bigger than my monitor... what do I do? (3 Replies)
Discussion started by: jjinno
3 Replies

9. Solaris

Pre-Login Screen Resolution

I'm trying to configure the resolution that the pre-login screen is set at, I have looked on the net and all I can find is people telling me to edit the 'm46config' file. I cant find this file anywhere in any directory. I'm running Solaris 10 - any ideas how I can alter the resolution? :confused: (1 Reply)
Discussion started by: Dredz
1 Replies

10. Solaris

Changing Screen Resolution

I have installed Solaris 10 over vmware onto my machine. Now when I want to change my screen resolution it only has one option which is 800x600. Is there a way to change that to a bigger resollution? And if there is, what file do I have to edit and what text editor do I have to use? (1 Reply)
Discussion started by: Aco
1 Replies
Login or Register to Ask a Question