optrandr - Set the X output in an optimal way


optrandr options...

optrandr -H


Analyze the existing outputs recognized by xrandr and set the optimal combination. See Meaning of optimal for what optimal means.



Output the command line but don't execute it.


If the call to xrandr setting the desired output fails optrandr normally tries again with slightly less optimal settings before reporting an error. With -o/--once this is not done.

This option is mainly useful for testing optrandr.


Use xrandr --query output on STDIN instead of calling xrandr and using it's output.

This option is mainly useful for testing optrandr.


Operate verbose.


Generate the man page for this program on standard output.

If an unknown option such as -. is given, a short usage message is generated.

Meaning of optimal

Optimal currently means the following.

This meaning may be modified by a variant. Variants are numbered from 0 upwards and variants beyond 0 are chosen if the last variant failed to set unless -o/--once has been given.

  1. Only first screen is considered

    Only the first screen reported (usually "Screen 0") is considered.

  2. Switch off disconnected outputs with known geometry

    Outputs disconnected but with known geometry are switched off so they don't influence the screen geometry.

  3. Only connected outputs are considered

    Outputs currently disconnected are not considered. Disconnected outputs with known geometry are switched off.

  4. Disable laptop display if there are others

    If there is more than one output and some of them are laptop displays disable the laptop displays.

    This reflects the use case where you have a closed laptop display in a docking station.

    This is not done if variant >= 1.

  5. Set a single display to the highest resolution and rate

    If there is one display left set this to the highest available resolution and rate.

  6. Configure multiple displays as clones

    If there are multiple displays left configure them to be clones of each other and set them to the highest common resolution.


  1. Ok.

  2. Command line was wrong.

  3. A problem occured.

  4. Errors while parsing xrandr output.

  5. Persistent errors while calling xrandr for setting screen.


Stefan Merten <>


This program is licensed under the terms of the GPL. See