31 March

xrandr example script

Switching an extra VGA monitor around on an OpenBSD laptop

To set up and configure an external monitor in X on OpenBSD, we typically use xrandr(1). There are some GUI tools (like lxrandr, from ports) to "help" with that, but for me, a very simple shell script can do the job:


# TODO: handle HDMI-3 / 4 / 5

case "$1" in
    xrandr --output VGA --same-as LVDS
    xrandr --output LVDS --off --output VGA --auto
    # external monitor is off, internal on
    xrandr --output LVDS --auto --output VGA --off
    xrandr --output VGA --auto --right-of LVDS
    xrandr --output VGA --auto --left-of LVDS
    # default fall through ...
    # external monitor is off, internal on
    xrandr --output LVDS --auto --output VGA --off

Usage: I save this as a script with the name "monitor" and then use it as one of monitor mirror, monitor right, ... etc.

When a more special setup is needed, this script can serve as a cheat sheet. Further than that, the xrandr man page is pretty good.

Differences to lxrandr: lxrandr doesn't do dual monitor setups (the ones where the extra monitor is used in addition to the internal one), it only does mirroring and "choose one of them". On the other hand, lxrandr handles changing of the resolutions. Also my script is only set up for the VGA port, if I ever get around to hook up something to the displayport, I'll have to adapt it.

Posted by betabug at 20:12 | Comments (0) | Trackbacks (0)
<< watch for syslog.conf | Main | openbsd ipsec.conf roadwarrior puzzlestone >>
There are no comments.
Please send trackback to: http://betabug.ch/blogs/bsdcow/46/tbping
There are no trackbacks.