Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

How do I find out my screen resolution from a shell script?

share|improve this question

4 Answers 4

up vote 22 down vote accepted
xdpyinfo  | grep dimensions
share|improve this answer

xdpyinfo | grep dimensions will give you the total resolution, if you have multiple monitors it will be the sum of all of them. xrandr --current will give you the resolution for each monitor.

I use this snippet to find the maximum posible resolution for rDesktop without going to full screen:

Xaxis=$(xrandr --current | grep '* ' | uniq | awk '{print $1}' |  cut -d 'x' -f1)

Yaxis=$(xrandr --current | grep '* ' | uniq | awk '{print $1}' |  cut -d 'x' -f2)

Output:

Xaxis = 1280
Yaxis = 1024

Minus windows decoration (more or less):

MaxRes=$(($Xaxis-5))"x"$(($Yaxis-25))

Output:

MaxRes = 1275x999

Which is the max resolution for rDesktop without going full screen.

End command:

rdesktop -u $User -P -z -5 -g $MaxRes $Host &

It works fine so far but I haven't tested thoroughly though.

share|improve this answer

You could use the xrandr -q command. From that you can create a shell script if needed.

For more information on the command go here or type man xrandr

share|improve this answer

xdpyinfo will do it, with some parsing. It gives a lot of info which you'll then have to dig the screen number, and dimensions from

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.