Custom graphical mode with xrandr

#! /bin/sh

Here is a script to add custom graphical modes to your Xorg session. This may allow to add mode not detected by the Xorg driver but the mode still have to be suppored by this driver. This was inspired by the Arch xrandr wiki page.

#! /bin/sh
fullmodeline=$(cvt "$@" | tail -n 1 | cut -d' ' -f2-)
# Remove the underscore and frequency from the mode name
modename=$(echo $fullmodeline | sed -r 's/\"(.+)_.*/\1/')
modeline="$modename $(echo $fullmodeline | cut -d' ' -f2-)"
monitor=$(xrandr | head -n 2 | tail -n 1 | cut -d' ' -f1)
# Remove the previously defined mode if any
xrandr --delmode $monitor $modename
xrandr --rmmode $modename
xrandr --newmode $modeline
xrandr --addmode $monitor $modename
# Enable the added mode
xrandr -s $modename


$ addmode 1024 600

#xorg, #xrandr