After setting the screen via GUI
In the line (in the output of xrandr
after you set the screen via GUI):
HDMI1 connected 1920x1080+1600+0 (normal left inverted right x axis y axis) 509mm x 286mm
the position of the second screen (HDMI1
) is defined top-allined, at he the right of your main screen (LVDS1
): 1920x1080+1600+0
, as explained here.
Before setting the screen via GUI
The definition of the position of your right screen seems to be missing for some reason.
I am not sure what causes the behaviour, might be a minor incompatibility, but it should be fixed with the command:
xrandr --output HDMI1 --pos 1600x0
Which will position the second screen at the right of the main screen, top- allined.
As you said when you plug the monitor before booting it gives a bad resolution, I believe adding a particular resolution in .profile
would solve this issue.
Open the terminal and run the following command.
xrandr
Note the display device name from the output.In my case its eDP-1.
next run the following command
cvt 1920 1080
Copy the whole Modeline from the output.
In my case it is as follows
"1920x1080_60.00" 173.00 1920 2048 2248 2576 1080 1083 1088 1120 -hsync +vsync.
And run the following command:
sudo xrandr --newmode "1920x1080_60.00" 173.00 1920 2048 2248 2576 1080 1083 1088 1120 -hsync +vsync
NOTE the command sections after --newmode
are copied from the output I got in the previous step.
Now add the newly created mode for your display device.
sudo xrandr --addmode eDP-1 "1920x1080_60.00"
Finally Apply the new resolution in the Display settings. Select the "1920x1080" resolution as your preferred resolution.
IMPORTANT: To make Ubuntu remember the new created screen resolution at next start, you have to edit your .profile
. Use any text editor, for example:
vim ~/.profile
add the last 2 commands to the end
Save and reboot. Hopefully the system will detect 1920x1080
resolution in both your displays.
Best Answer
You can use the following command:
or
depending how your screen are arranged in System Settings → Displays.
See
man xrandr
for more info.