Mon Oct 28, 2013 4:49 pm
#!/usr/bin/env bash
echo "
Run this script with no options for 1280x1024.
For any other resolutions, put the horizontal and vertical
sizes on the command line.
Example:
fixdisplay 1400 900
"
# Get the modeline from the command:
# cvt 1280 1024
#
# Use default display resolution if they
# aren't given in the command arguments.
if [[ $1 ]] ; then
horiz_res="$1"
else
horiz_res="1280"
fi
if [[ $2 ]] ; then
vert_res="$2"
else
vert_res="1024"
fi
list=$(cvt $horiz_res $vert_res | awk '/Modeline/ { print $3 " " $4 " " $5 " " $6 " " $7 " " $8 " " $9 " " $10 " " $11 }')
modeline="$list"
echo -e "\nModeline for $horiz_res x $vert_res"
echo "${modeline[0]}"
all_outputs=$(xrandr | awk '/ connected/ { print $1 }')
echo "
If all_outputs = default (see below) then this script
probably won't work. You can try it, or you can abort by
pressing ctrl-c
"
echo -e "\tall_outputs = $all_outputs"
#if $(echo $all_outputs | grep -q ^default) ; then
# echo "Exit due to error."
# exit 1
#fi
#sleep 2
#echo " Enter an output from this list:
#$all_outputs
#: "
#read output
echo -e "\nSelect a video output from the list:"
select output in "$all_outputs" ; do
echo "$output"
break
done
xrandr --newmode disp$horiz_res ${modeline[@]}
sleep 2
echo "1111"
xrandr --addmode "$output" disp$horiz_res
sleep 2
echo "2222"
xrandr --output "$output" --mode disp$horiz_res
echo "3333"
exit 0