Create and Save the resolution mode on Ubuntu 14.04

When I plugged in another monitor on my PC these days, I couldn’t find the correct resolution mode in “System Settings” of my Ubuntu 14.04. It shows that it’s an unknown display device.

So I tried to set the resolution mode manually.

  1. Get the device name of monitor
    Type

                    sudo xrandr
                    

    in the shell
    And you will get something like

                    Screen 0: minimum 320 x 200, current 3840 x 1080, maximum 16384 x 16384
                    HDMI-0 disconnected (normal left inverted right x axis y axis)
                    DVI-0 connected primary 1920x1080+1920+0 (normal left inverted right x axis y axis) 510mm x 290mm
                       1920x1080      60.0*+
                       1680x1050      59.9  
                       1280x1024      75.0     60.0  
                       1280x960       60.0  
                       1152x864       75.0  
                       1024x768       75.1     60.0  
                       832x624        74.6  
                       800x600        75.0     60.3     56.2  
                       640x480        75.0     60.0  
                       720x400        70.1  
                    VGA-0 connected 1920x1080+0+0 (normal left inverted right x axis y axis) 0mm x 0mm
                       1024x768       60.0*  
                       800x600        60.3     56.2  
                       848x480        60.0  
                       640x480        59.9  
                    

    The phrase in capital letter is your devices name.
    For example VGA-0
    The list of numbers below it is the resolution mode the device supports.
    A * means the device is working under this mode.
    A + means the device prefers to working under this mode.
    As you can see, there is no 1920×1080 mode in my VGA-0 list.

  2. Find out what the resolution mode you want. Then you can type

    	        cvt 1920 1080   #I will take 1920*1080 as an example here
    	        

    in shell. And you will get something like

    	        # 1920x1080 59.96 Hz (CVT 2.07M9) hsync: 67.16 kHz; pclk: 173.00 MHz
                    Modeline "1920x1080_60.00"  173.00  1920 2048 2248 2576  1080 1083 1088 1120 -hsync +vsync
    	        

    Write down the Modeline

  3. Tpye

                    sudo xrandr --newmode "1920x1080_60.00"  173.00  1920 2048 2248 2576  1080 1083 1088 1120 -hsync +vsync #Here is the Modeline you get from cvt
                    sudo xrandr --addmode VGA-0 "1920x1080_60.00"   #I will take the VGA-0 for example
                    
  4. After these steps, you can find the “1920×1080” Option in your System Setting
    Choose this one to preview the result.

Now it’s time to make these change permanently

  1. Create a shell script and save

                    sudo xrandr --newmode "1920x1080_60.00"  173.00  1920 2048 2248 2576  1080 1083 1088 1120 -hsync +vsync #Here is the Modeline you get from cvt
                    sudo xrandr --addmode VGA-0 "1920x1080_60.00"   #I will take the VGA-0 for example
                    

    in it.
    Make it runnable !

  2. Add this line to /usr/share/lightdm/lightdm.conf.d/50-ubuntu.conf

                    session-setup-script=/your/runnable/script.sh   #Filled with the script location you created above
                    

Now you can reboot and the Unity will remeber what you want!