Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I would like to run a command like get-screen-resolution during a X session to get a '800x480' output. ( or whatever the actual screen size is ).

Is there something available for this? Currently I take a screenshot and measure the resulting *.jpg's width & height attributes.

Also, how do I set the screensize during a X session from the command-line?

share|improve this question
add comment

2 Answers 2

up vote 7 down vote accepted

You can use xrandr to do both

Get resolution

$ xrandr
Screen 0: minimum 320 x 240, current 1920 x 1080, maximum 1920 x 1080
default connected 1920x1080+0+0 0mm x 0mm

Set resolution

$ xrandr --output default --mode 1280x1024
share|improve this answer
add comment

From my personal shell library:

get_screen_size()
{
    xdpyinfo | awk '/dimensions:/ { print $2; exit }'
}
share|improve this answer
add comment

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.