You are not logged in.
Pages: 1
The other day I was preparing my netbook for giving a presentation with an external projector. I knew that new versions of xrandr support scaling of the image, so you can have a full resolution in the external output (1024x768, 1280x1024, whatever) and still see the whole image on the small 1024x600 display of the netbook. I did a quick search but did not find any tools for dealing with this automatically, so I wrote my own dualMonitor.sh in a quick&dirty way:
#!/bin/zsh
function vgaModes() {
# Probably should do this more robust
xrandr | grep -A1000 VGA1 | grep -B 10000 LVDS1 | tail -n+2 | head -n-1
}
function vgaOn() {
res=$1
if [[ "$res" == "" ]]; then
res=`vgaModes | awk 'NR == 1 { print $1; }'`
fi
xres=${res/x*}
yres=${res/*x}
xrandr --output VGA1 --mode $res \
--output LVDS1 --mode 1024x600 --scale $(($xres/1024.0))x$(($yres/600.0))
}
function vgaOff() {
xrandr --output VGA1 --off \
--output LVDS1 --mode 1024x600 --scale 1x1
}
function vgaToggle() {
# Make an educated guess if vga is connected
modesOutput=`vgaModes`
if [[ "$modesOutput" == "" ]] || (echo $modesOutput | grep \* >& /dev/null); then
echo "Turning VGA Off"
vgaOff
else
echo "Turning VGA On"
vgaOn
fi
}
case "$1" in
off)
vgaOff
;;
"")
vgaToggle
;;
*)
vgaOn $1
;;
esac
Usage should be quite straightforward. Called without arguments it toggles the external display, trying to use the best available resolution (at least, the first one reported by xrandr). You can also specify a different resolution by providing it as parameter, e.g.
dualMonitor.sh 1024x768
Called with "off" as argument it turns the external display off.
As I said, this was done in a quick&dirty way, e.g. the names of the outputs are hardcoded (LVDS1, VGA1) as well as the resolution of my netbook displat (1024x600), the vgaModes function is quite ugly, etc. But I find it quite useful, so I post it here and perhaps we can combine efforts to make it more robust and try it on other configurations. BTW. I used zsh as scripting language in order to have floating point arithmetic when computing the scaling factors.
Offline
Offline
LXRandR ?
Correct me if I'm wrong, but, looking at the description, it seems it does not support scaling (quite important for the small netbook display). The same thing that I miss in other frontends I found.
Offline
Pages: 1