Ubuntu – Permanently set the resolution for the second monitor

multiple-monitorsresolutionunity

After every restart, I have to manually set the resolution of my second monitor with:

sudo xrandr --newmode "1600x900_60.00"  118.25  1600 1696 1856 2112  900 903 908 934 -hsync +vsync
sudo xrandr --addmode VGA-0 "1600x900_60.00"

Unity never picks up the resolution automatically, so is there a way to set this permanently so I don't need to do it every time?

Best Answer

I don't think you need to use sudo here, in fact you shouldn't if it is unnecessary.

Simply create a small script:

#!/bin/bash

xrandr --newmode "1600x900_60.00"  118.25  1600 1696 1856 2112  900 903 908 934 -hsync +vsync
xrandr --addmode VGA-0 "1600x900_60.00"
  • Copy it into an empty file, save it as set_resolution.sh
  • Add it to your startup applications: Dash > Startup Applications > Add the command:

    /bin/bash /path/to/set_resolution.sh
    

NB

You might have to add a small break to wait for the desktop to be fully loaded, e.g.:

#!/bin/bash

sleep 10
xrandr --newmode "1600x900_60.00"  118.25  1600 1696 1856 2112  900 903 908 934 -hsync +vsync
xrandr --addmode VGA-0 "1600x900_60.00"