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

link|improve this question

75% accept rate
feedback

4 Answers

up vote 6 down vote accepted
xdpyinfo  | grep dimensions
link|improve this answer
feedback

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

link|improve this answer
feedback

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

link|improve this answer
feedback

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.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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