31 March
2012

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:

#!/bin/sh

# TODO: handle HDMI-3 / 4 / 5

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

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 >>
Comments
There are no comments.
Trackbacks
Please send trackback to: http://betabug.ch/blogs/bsdcow/46/tbping
There are no trackbacks.
Leave a comment
Please note: Comments are moderated. Your comment will not show up until I can have a look at it and decide it's not SPAM. Sorry for the inconvenience.