Set Up Multiple Displays
Multi-views represent a setup when multiple display devices are attached to a computer. This is an easy configuration adapted from Arch office site.
Three ways to setup multiple-head displays with xrandr:
- to use xrandr to id and setup up monitors manually,
- to use arandr (gui version) -the easiest way, yet it is very powerful comparing with MS Windows.
- or with the help of a script to automatically detect monitors hooked up to your Linux Box and setup multiple-head display.
Identify attached monitors
1 2 3 |
xrandr |
two monitors (e.g.): VGA-0 and LVDS (builtin LCD) setting dual monitor view with following code
1 2 3 |
xrandr --output LVDS --mode 1024x768 --output VGA-0 --mode 1920x1080 --left-of LVDS |
A more elegant way of using a script.
This script iterates over all xrandr outputs. If anything is connected it tries to figure out the best possible resolution places that right-of the previous display.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
#!/bin/bash XRANDR="xrandr" CMD="${XRANDR}" declare -A VOUTS eval VOUTS=$(${XRANDR}|awk 'BEGIN {printf("(")} /^\S.*connected/{printf("[%s]=%s ", $1, $2)} END{printf(")")}') declare -A POS #XPOS=0 #YPOS=0 #POS="${XPOS}x${YPOS}" POS=([X]=0 [Y]=0) find_mode() { echo $(${XRANDR} |grep ${1} -A1|awk '{FS="[ x]"} /^\s/{printf("WIDTH=%s\nHEIGHT=%s", $4,$5)}') } xrandr_params_for() { if [ "${2}" == 'connected' ] then eval $(find_mode ${1}) #sets ${WIDTH} and ${HEIGHT} MODE="${WIDTH}x${HEIGHT}" CMD="${CMD} --output ${1} --mode ${MODE} --pos ${POS[X]}x${POS[Y]}" POS[X]=$((${POS[X]}+${WIDTH})) return 0 else CMD="${CMD} --output ${1} --off" return 1 fi } for VOUT in ${!VOUTS[*]} do xrandr_params_for ${VOUT} ${VOUTS[${VOUT}]} done set -x ${CMD} set +x |
Notes: fail to boot after modified xorg.conf
4
MAR
MAR
About the Author:
Beyond 8 hours - Computer, Sports, Family...