BASENAME="`basename $0`"
X="$1"
Y="$2"
+INTERFACE="$3"
# Check
if [ -z "$Y" ]; then
- echo "usage: $BASENAME <x-res> <y-res>"
+ echo "usage: $BASENAME <x-res> <y-res> <interface>"
exit 1
elif ! which cvt &> /dev/null; then
echo "please install cvt from xserver-xorg-core"
# Get modeline and interface
MODELINE="`cvt $X $Y | grep -v '^#' | sed -e 's/^Modeline //'`"
-INTERFACE="`xrandr | grep " connected" | cut -d ' ' -f 1 | head`"
NAME="`echo $MODELINE | cut -d ' ' -f 1 | sed -e 's/"//g'`"
+# Fallback to the first connected interface found
+if [ -z "$INTERFACE" ]; then
+ INTERFACE="`xrandr | grep " connected" | cut -d ' ' -f 1 | head -1`"
+fi
+
# Apply
xrandr --newmode $MODELINE &> /dev/null
xrandr --addmode $INTERFACE $NAME