Why don't my lightdm.conf edits affect my desktop screen resolution?

Solution 1:

I tried a similar thing and after some debugging I think I figured out what's going on. Your script probably is run and probably does set the resolution correctly. However, since it is run by the login manager, it runs before Unity has finished setting up your desktop environment and Unity reads its own settings and resets the resolution to what you had. So, I think that what happens is:

  1. lightdm correctly runs your script
  2. This sets your desired resolution
  3. Unity launches, reads its settings and reverts to the default resolution you have there
  4. Your resolution goes back to what it was before

Now, this happens because the VESA driver does not detect your desired resolution automatically. This means that when you change the resolution from the Displays section of Unity's settings, you are giving it a resolution that is not available unless you run the xrandr commands. Therefore, this is ignored next time you restart and Unity reverts to the default resolution.

So, what you need to do is make the resolution available to Unity, then set it as default and let it handle it. To do so, you must first add this line to /usr/share/lightdm/lightdm.conf.d/50-ubuntu.conf:

session-setup-script=/usr/bin/lightdmxrandr.sh

Then, make sure that /usr/bin/lightdmxrandr.sh looks like this:

xrandr --newmode "1368x768_60.00"   85.25  1368 1440 1576 1784  768 771 781 798 -hsync +vsync  
xrandr --addmode DVI-0 1368x768_60.00  

Note that I am not actually setting the resolution, only making it available. Once you have done this restart, then log in. The new resolution should now be available in Settings => Displays. If so, choose it there, log out and log back in again and the resolution should be set correctly.It should now persist across reboots.


Alternative approaches:

  1. Create an /etc/X11/xorg.conf file that lists your desired resolution. Something like this:

    Section "Monitor"
        Identifier    "Monitor0"
        Modeline "1368x768_60.00"  109.00  1280 1368 1496 1712  1024 1027 1034 1063 -hsync +vsync
    EndSection
    
    Section "Screen"
        Identifier     "Screen0"
        Device         "Card0"
        Monitor        "Monitor0"
        SubSection "Display"
            Modes       "1368x768_60.00"
        EndSubSection
    EndSection
    
    Section "Device"
        Identifier    "Card0"
        Driver        "vesa"
    EndSection
    
  2. Add the script that runs the xrandr commands to your session's startup applications.