[Nottingham] Short cut to fix screen resolution

Peter Chang Peter.Chang at nottingham.ac.uk
Thu Dec 14 13:43:30 GMT 2006


On Thu, 14 Dec 2006, Moppett Iain wrote:
> -----
> #!/bin/sh
> # run game
> res="$(xrandr -q|grep '^\*')"
> if [[ "${res:1:1}" != 0 ]]; then
>        xrandr -s 0
> Fi
> ---------
> Is there any need to include all the grep bits?  I have no idea what it
> means.  I assume that its looking for a regular expression, but it all
> seems abit complicated.

If you just execute "xrandr -q", you see that it lists the set of possible 
screen resolutions. The grep is to get the active one indicated by an "*". 
The (arithmetic) shell test, using a substring expansion, is to see if the 
active resolution has an index of 0. If not, then the xrandr command is 

So basically it's a method to avoid set the resolution to the first one 
listed if the screen is already set at that.


This message has been checked for viruses but the contents of an attachment
may still contain software viruses, which could damage your computer system:
you are advised to perform your own checks. Email communications with the
University of Nottingham may be monitored as permitted by UK legislation.

More information about the Nottingham mailing list