Development

Ubuntu 16.04 / monitor resolution/rotation is reset after rebooting

건이두 2018. 12. 4. 20:47
728x90

# Problem regarding monitor resolution/rotation

Problem is whenever my Ubuntu 16.04 is rebooted, two monitors resolution/rotations are reset.

After every rebooting, I should reset monitor resolution/rotation manually.


# Prerequisites

## Common steps

arandr should be installed properly


## If you are using NVIDIA graphic card

nvidia-settings should be installed properly.


# Analysis from log

## Monitor's resolution/rotation is reset by someone else


According /var/log/Xorg.0.log , I could observe that once resolutions/rotation is set correctly,

And then in the last log, they are reset by someone else


### Intended monitor resolution/rotation

As I described on /etc/X11/x.org, resolution/rotation are set correctly.


[    40.453] (II) NVIDIA(0): Validated MetaModes:

[    40.453] (II) NVIDIA(0):    

[    40.453] (II) NVIDIA(0):     "HDMI-0:1920x1080@1080x1920+1080+0{rotation=left},DVI-I-1:1920x1080+0+0{rotation=left}"

[    40.453] (II) NVIDIA(0): Virtual screen size determined to be 2160 x 1920

[    40.457] (--) NVIDIA(0): DPI set to (51, 162); computed from "UseEdidDpi" X config

[    40.457] (--) NVIDIA(0):     option

[    40.457] (--) Depth 24 pixmap format is 32 bpp

[    40.457] (II) NVIDIA: Using 6144.00 MB of virtual memory for indirect memory

[    40.457] (II) NVIDIA:     access.

[    40.538] (II) NVIDIA(0): Setting mode "HDMI-0:1920x1080@1080x1920+1080+0{rotation=left},DVI-I-1:1920x1080+0+0{rotation=left}"


### Monitor resolution/rotation is reset

However, 12 seconds later, resolution/rotation are set by 'nvidia-auto-select'.

I couldn't find where the nvidia-setttings set resolution/rotation again.


[    52.776] (II) NVIDIA(0): Setting mode "DVI-I-1: nvidia-auto-select @1920x1080 +0+0 {ViewPortIn=1920x1080, ViewPortOut=1920x1080+0+0}"

[    52.926] (II) NVIDIA(0): Setting mode "DVI-I-1: nvidia-auto-select @1080x1920 +0+0 {ViewPortIn=1080x1920, ViewPortOut=1920x1080+0+0, Rotation=90}"

[    52.993] (II) NVIDIA(0): Setting mode "HDMI-0: nvidia-auto-select @1080x1920 +1080+0 {ViewPortIn=1080x1920, ViewPortOut=1920x1080+0+0, Rotation=90}, DVI-I-1: nvidia-auto-select @1080x1920 +0+0 {ViewPortIn=1080x1920, ViewPortOut=1920x1080+0+0, Rotation=90}"


# Workaround

Although, I couldn't find a right/best solution for this problem, however, we can avoid setting monitor's resolution/rotation manually. :-)


## Set resolution/rotation manually

We should set monitor's resolution/rotation manually, don't worry, it is the last time to set it manually.

By using xrandr or nvidia-settings (proper utility), set resolution/rotation as you want.


## Automatically set by using arandr


By default, xrandr is able to set resolution/rotation. but it is command line utility, arandr have its GUI and moreover, it can generate script like below.


### Installing arandr

sudo apt-get install arandr


### Generating script

Run arandr, and click 'disk' icon to save current monitor's resolution/rotation as xrandr script.


bkk@bkk-dt:~/bin$ cat mylayout.sh 

#!/bin/sh

xrandr --output VGA-0 --off --output DVI-I-1 --primary --mode 1920x1080 --pos 0x0 --rotate left --output DVI-I-0 --off --output HDMI-0 --mode 1920x1080 --pos 1080x0 --rotate left


## Almost done, run mylayout.sh automatically, by using gnome-session-properties

gnome-session-properties is able to run some script whenever you log in.

Please add mylayout.sh into it, it will free you from setting resolution/rotation manually.

728x90