I made this small script to help me rapidly connect to external monitors, when I am in a hurry.
For example, if I have to do a presentation at the university, I just connect the VGA output and type
$ vga_conf VGA1 1024 768 60
and that gives me 1024×768@60Hz on the beamer.
The script is extra-simple and doesn’t handle all situations. It’s just a quick way to try to set your resolution and refresh rate when in a hurry.
#!/bin/bash
if [ $# != 4 ]; then
echo "** Usage: "
echo "** $0 output height width refresh_rate"
echo "** Example usage:"
echo "** $0 VGA1 1280 1024 60"
echo "** Note: output name can be retrieved from the xrandr command"
exit
fi
echo "Generating modeline..."
modeline=`gtf $2 $3 $4 | grep Modeline | cut -f3 -d' ' --complement`
mode=`echo $modeline | cut -f1 -d' '`
echo "Creating modeline: $modeline"
xrandr --newmode $modeline
echo "Adding mode $mode to output $1"
xrandr --addmode $1 $mode
echo "Setting mode of $1 to $mode";
xrandr --output $1 --mode $mode
Advertisement