Some of your commands are a little old or unnecessary. Here's a slightly updated version (note that I'm using the name 'custom' to illustrate that the mode name can be anything you want). Save it to a bash script:
#!/usr/bin/env bash
cvt 1366 768
xrandr --newmode "custom" 85.25 1368 1440 1576 1784 768 771 781 798 -hsync +vsync
xrandr --addmode VGA1 custom
xrandr --output VGA1 --mode custom
As for it being slow, it could be due to something trying to load early, xrandr scripts can cause problems if that happens.
Make sure your bash script is at least executable. No harm in making it readable by everyone too, so chmod 755
on the script file.
Bear in mind you may need to access the terminal in recovery mode to undo your changes/comment out problematic lines if anything goes wrong.
Using Startup Applications:
Add your script to Startup Applications the same way you added your concatenated commands. If the above script doesn't solve your problem try adding sleep 10
just below #!/bin/bash
.
The higher the sleep
value the more guarantee you have that xrandr won't start early, but it may delay your monitors appearing properly - play around with the time so you get it how you want it.
Using LightDM (Edit - this may not work in 16.x due to Unity jumping in and resetting changes made in your script):
There should also be a way to get execute the script using system hooks in LightDM config files; this is probably the 'proper' way of doing things these days.
Go to /usr/share/lightdm/lightdm.conf.d
and create a file called monitors.conf
.
In there add a seat
heading then one or all of the following commands:
[Seat:*]
display-setup-script=/path/to/your/script
greeter-setup-script=/path/to/your/script
session-setup-script=/path/to/your/script
Play around to try and get your desired behaviour. For me, most of the script runs as it's supposed, but the xrandr --output
commands don't work. Not sure if it's my setup or they're being fired at the wrong time, from some other posts I've seen it works just fine for other people.
I'll carry on investigating and update if I find a clearer answer.
Having said all that though, Linux Display Managers just aren't that great - startup time can be slow, and performance will probably be worse than Windows.