Persisting scaled modeline to xorg.conf

Hi everyone!

I’ve got a WQHD monitor (2560x1440 resolution) and I’m trying to persist a modeline which scales the resolution 1.5x using a Transform.

Having set window and text scaling to 2x in GNOME, the scaled modeline smoothly scales back down 1.5x to achieve a HiDPI resolution that looks like 1920x1080:

2560x1440x1.5 = 3840x2160 (1.5x display scaling)
3840x2160/2 = 1920x1080 (2x GNOME/GTK window/text scaling)

I have managed to achieve this both through xrandr and via setting the current modeline with a transform through nvidia-settings:

nvidia-settings --assign "CurrentMetaMode=DPY-1: nvidia-auto-select @3840x2160 +0+0 {Transform(1.500000,0.000000,0.000000,0.000000,1.500000,0.000000,0.000000,0.000000,1.000000), ViewPortIn=3840x2160, ViewPortOut=2560x1440+0+0}"

This works perfectly, however I cannot persist this setup via xorg.conf (added line 25):

...
Section "Monitor"
    Identifier     "Monitor0"
    VendorName     "Unknown"
    ModelName      "AOC 2778X"
    HorizSync       30.0 - 99.0
    VertRefresh     50.0 - 76.0
    Option         "DPMS"
EndSection

Section "Device"
    Identifier     "Device0"
    Driver         "nvidia"
    VendorName     "NVIDIA Corporation"
    BoardName      "GeForce GTX 1060 6GB"
EndSection

Section "Screen"
    Identifier     "Screen0"
    Device         "Device0"
    Monitor        "Monitor0"
    DefaultDepth    24
    Option         "Stereo" "0"
    Option         "nvidiaXineramaInfoOrder" "DFP-1"
    Option         "metamodes" "DPY-1: nvidia-auto-select @3840x2160 +0+0 {Transform=(1.500000,0.000000,0.000000,0.000000,1.500000,0.000000,0.000000,0.000000,1.000000), ViewPortIn=3840x2160, ViewPortOut=2560x1440+0+0}"
    Option         "SLI" "Off"
    Option         "MultiGPU" "Off"
    Option         "BaseMosaic" "off"
    SubSection     "Display"
        Depth       24
    EndSubSection
EndSection

My Xorg logs after logging in and entering a GNOME session show that the modeline is recognized and validated:

...
Jun 07 20:36:29 sihaya.localdomain /usr/libexec/gdm-x-session[32452]: (WW) NVIDIA(0):     was also specified.
Jun 07 20:36:29 sihaya.localdomain /usr/libexec/gdm-x-session[32452]: (II) NVIDIA(0): Validated MetaModes:
Jun 07 20:36:29 sihaya.localdomain /usr/libexec/gdm-x-session[32452]: (II) NVIDIA(0):
Jun 07 20:36:29 sihaya.localdomain /usr/libexec/gdm-x-session[32452]: (II) NVIDIA(0):     "DPY-1:nvidia-auto-select@3840x2160+0+0{Transform=(1.500000,0.000000,0.000000,0.000000,1.500000,0.000000,0.000000,0.00000
Jun 07 20:36:29 sihaya.localdomain /usr/libexec/gdm-x-session[32452]: (II) NVIDIA(0): Virtual screen size determined to be 3840 x 2160
Jun 07 20:36:29 sihaya.localdomain /usr/libexec/gdm-x-session[32452]: (--) NVIDIA(0): DPI set to (162, 161); computed from "UseEdidDpi" X config
Jun 07 20:36:29 sihaya.localdomain /usr/libexec/gdm-x-session[32452]: (--) NVIDIA(0):     option
Jun 07 20:36:29 sihaya.localdomain /usr/libexec/gdm-x-session[32452]: (--) Depth 24 pixmap format is 32 bpp
Jun 07 20:36:29 sihaya.localdomain /usr/libexec/gdm-x-session[32452]: (II) NVIDIA: Using 49152.00 MB of virtual memory for indirect memory
Jun 07 20:36:29 sihaya.localdomain /usr/libexec/gdm-x-session[32452]: (II) NVIDIA:     access.
Jun 07 20:36:29 sihaya.localdomain /usr/libexec/gdm-x-session[32452]: (II) NVIDIA(0): ACPI: failed to connect to the ACPI event daemon; the daemon
Jun 07 20:36:29 sihaya.localdomain /usr/libexec/gdm-x-session[32452]: (II) NVIDIA(0):     may not be running or the "AcpidSocketPath" X
Jun 07 20:36:29 sihaya.localdomain /usr/libexec/gdm-x-session[32452]: (II) NVIDIA(0):     configuration option may not be set correctly.  When the
Jun 07 20:36:29 sihaya.localdomain /usr/libexec/gdm-x-session[32452]: (II) NVIDIA(0):     ACPI event daemon is available, the NVIDIA X driver will
Jun 07 20:36:29 sihaya.localdomain /usr/libexec/gdm-x-session[32452]: (II) NVIDIA(0):     try to use it to receive ACPI event notifications.  For
Jun 07 20:36:29 sihaya.localdomain /usr/libexec/gdm-x-session[32452]: (II) NVIDIA(0):     details, please see the "ConnectToAcpid" and
Jun 07 20:36:29 sihaya.localdomain /usr/libexec/gdm-x-session[32452]: (II) NVIDIA(0):     "AcpidSocketPath" X configuration options in Appendix B: X
Jun 07 20:36:29 sihaya.localdomain /usr/libexec/gdm-x-session[32452]: (II) NVIDIA(0):     Config Options in the README.
Jun 07 20:36:29 sihaya.localdomain /usr/libexec/gdm-x-session[32452]: (II) NVIDIA(0): Setting mode "DPY-1:nvidia-auto-select@3840x2160+0+0{Transform=(1.500000,0.000000,0.000000,0.000000,1.500000,0.000000,0.00000
Jun 07 20:36:29 sihaya.localdomain /usr/libexec/gdm-x-session[32452]: (==) NVIDIA(0): Disabling shared memory pixmaps
Jun 07 20:36:29 sihaya.localdomain /usr/libexec/gdm-x-session[32452]: (==) NVIDIA(0): Backing store enabled
Jun 07 20:36:29 sihaya.localdomain /usr/libexec/gdm-x-session[32452]: (==) NVIDIA(0): Silken mouse enabled
...

However later on in the logs (almost at the end) the modeline gets set back to 2560x1440:

...
Jun 07 20:36:30 sihaya.localdomain /usr/libexec/gdm-x-session[32452]: (II) NVIDIA(0): Setting mode "NULL"
Jun 07 20:36:30 sihaya.localdomain /usr/libexec/gdm-x-session[32452]: (II) NVIDIA(0): Setting mode "HDMI-0: nvidia-auto-select @2560x1440 +0+0 {ViewPortIn=2560x1440, ViewPortOut=2560x1440+0+0}"
...

Full Xorg log here: https://gist.github.com/anonymous/78bf25406d66dba423b03a5e3ccaf634.

I just can’t seem to get the modeline to stick!

Details:

Fedora 25
Nvidia driver version 375.66

~ ls -al /etc/X11/xorg.conf.d 
total 12
drwxr-xr-x. 2 root root 4096 May 25 22:07 .
drwxr-xr-x. 6 root root 4096 Jun  7 22:47 ..
-rw-r--r--. 1 root root  232 May 28 18:19 00-keyboard.conf

~ ls -al /usr/share/X11/xorg.conf.d 
total 32
drwxr-xr-x. 2 root root 4096 May 28 22:32 .
drwxr-xr-x. 7 root root 4096 May 28 18:31 ..
-rw-r--r--. 1 root root 1099 Jan 18 04:05 10-evdev.conf
-rw-r--r--. 1 root root 1350 Mar 15 18:38 10-quirks.conf
-rw-r--r--. 1 root root 1140 May 18 06:33 60-libinput.conf
-rw-r--r--. 1 root root 2747 Mar  8 23:22 70-wacom.conf
-rw-r--r--. 1 root root  198 May 18 06:33 71-libinput-overrides-wacom.conf
-r--r--r--. 1 root root  489 May 28 22:32 nvidia-drm-outputclass.conf

There is a .nvidia-settings-rc file in my home directory but there is nothing inside this that looks like it sets video modes or scaling. I have also tried deleting this file.

Any help is much appreciated!
Thanks, Chris.

Check what resolution you set in GNOME display property tool. GNOME might be applying persistent mode after login. Check explanation of “The display settings I configured in nvidia-settings do not persist.” in http://us.download.nvidia.com/XFree86/Linux-x86_64/375.66/README/commonproblems.html