Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
google site



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

Closed Thread
English Japanese Spanish French German Portuguese Italian Powered by Powered by Google
 
Search this Thread
  #1  
Old 12-24-2009
Registered User
 

Join Date: Dec 2009
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
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
Sponsored Links
  #2  
Old 12-24-2009
TonyFullerMalv's Avatar
Registered User
 

Join Date: Sep 2008
Location: Malvern, Worcs. U.K.
Posts: 1,021
Thanks: 0
Thanked 1 Time in 1 Post
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 02:24 PM..
  #3  
Old 12-25-2009
Registered User
 

Join Date: Dec 2009
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Thumbs up

Thank you. This solves my problem.
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
screen resolution tirupathi Solaris 2 06-21-2009 04:25 AM
Screen Saver Resolution ambavaram Solaris 2 06-19-2008 12:48 PM
Changing my Screen Resolution (Not in X) jjinno UNIX for Dummies Questions & Answers 3 07-18-2007 02:53 PM
Pre-Login Screen Resolution Dredz Solaris 1 07-21-2005 08:14 AM
Changing Screen Resolution Aco Solaris 1 07-18-2005 04:55 PM



All times are GMT -4. The time now is 11:11 PM.