LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 09-14-2006, 04:36 PM   #1
VlnChemE
LQ Newbie
 
Registered: Feb 2006
Posts: 3

Rep: Reputation: 0
Find screen resolution in X11


I would like to create a script that will create xterms of a certain size depending on the screen resolution. I have not been able to find a way to get the screen resolution (other than by setting it in xorg.conf, etc...). Any suggestions?

Thank you in advance.
 
Old 09-14-2006, 05:39 PM   #2
Leisy
Member
 
Registered: Sep 2006
Location: Brno, Czech Republic
Distribution: Fedora
Posts: 56

Rep: Reputation: 15
gnome-display-properties from gnome control center are showing that but in its own window...but sources can give a clue
 
Old 09-14-2006, 06:07 PM   #3
Leisy
Member
 
Registered: Sep 2006
Location: Brno, Czech Republic
Distribution: Fedora
Posts: 56

Rep: Reputation: 15
Or you can try something like this:

# grep "Virtual size" /var/log/Xorg.0.log | awk '{ print $6; };'
1400x1050
 
Old 09-14-2006, 06:33 PM   #4
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,396
Blog Entries: 2

Rep: Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903
That only tells you the size of an X server running on the computer your shell is running on. This will tell you about the X server you are actually viewing (which is more likely what you want).

Code:
xdpyinfo | grep dimensions | awk '{print $2;}'
--- rod.
 
Old 09-14-2006, 09:18 PM   #5
JrLz
Member
 
Registered: Mar 2004
Location: Jakarta
Posts: 164

Rep: Reputation: 30
try to use xrandr command
 
Old 09-14-2006, 09:20 PM   #6
VlnChemE
LQ Newbie
 
Registered: Feb 2006
Posts: 3

Original Poster
Rep: Reputation: 0
Thank you Rob

Thank you Rod (theNbomr). The xdpyinfo worked. I did not know of that command and my searches with man -k did not bring it up as screen and/or resolution are not in the man description. Thank you again.
 
Old 09-19-2006, 07:38 PM   #7
VlnChemE
LQ Newbie
 
Registered: Feb 2006
Posts: 3

Original Poster
Rep: Reputation: 0
Final script line

Here are the lines of a shell script (sh) that allowed me to calculate the ratio of the screen width:height and then use that ratio to decide the height of an xterm that will be created.

Thanks again for all your help.

# get ratio of width to height of screen
res=`xdpyinfo | grep dimensions | awk '{print $2}' | sed -e 's/x/\//'`
RATIO=`echo scale=4';' $res | bc`
if [ $RATIO > 1.5 ]; then
XTERMH=20;
else
XTERMH=30;
fi

Last edited by VlnChemE; 09-20-2006 at 08:38 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
default screen resolution smaller than max. resolution ?? Thoddy Linux - General 2 11-10-2005 02:33 AM
X11 Resolution - not read from xorg.conf felixc Linux - Newbie 3 10-24-2005 05:27 PM
using linux without X11 with 1024*768 resolution gaddargarson Fedora 3 04-05-2005 11:47 AM
using linux without X11 with 1024*768 resolution gaddargarson Slackware 3 04-04-2005 04:11 PM
X11 Monitor Resolution. DdTComp Slackware 5 10-18-2004 12:31 AM


All times are GMT -5. The time now is 02:24 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration