1

I have a new 4k monitor. I'd like to zoom its desktop by 25%. After boot or logging in, I usually run this command manually:

xrandr --output HDMI-1 --fb 4992x1728 --mode 3840x2160 --scale 0.8x0.8 --pos 0x0 --primary \
   --output HDMI-0 --mode 1920x1080 --scale 1x1 --pos 3072x0

It sets up my GUI, resolutions, and positions of two monitors around a virtual desktop exactly as I expect.

The problem is this command doesn't work if I put it in the ~/.xprofile. The outcome seems to vary between relogs: sometimes the screen is not scaled at all, sometimes it is but desktop locations around the virtual desktop are not clear. If the ~/.xprofile is not a correct place to configure the GUI when X session starts, what is the alternative? Is it just the ~/.profile? I don't know if ~/.profile is run only once per user session or multiple times. It might be important because when xrandr is run multiple times, it may also cause problems. In terms of errors regarding the command in the ~/.xprofile, how can I know what exactly happens when X session starts. Is there any log file?

Thanks

Celdor
  • 234

1 Answers1

1

The method used by others (linked in comments) is considered "hack" by OP. Which I guess it might be.

Using X configuration file which is loaded before login screen and not after login can be done here:

$ cat /etc/X11/xorg.conf
Section "ServerLayout"
    Identifier "layout"
    Screen 0 "nvidia"
    Inactive "intel"
EndSection

Section "Monitor"
    Identifier "DP-1-1"
    Modeline "3840x2160_54.00"  637.50  3840 4152 4568 5296  2160 2163 2168 2230 -hsync +vsync
    Option "PreferredMode" "3840x2160_54.00"
EndSection

Section "Device"
    Identifier "intel"
    Driver "modesetting"
    BusID "PCI:0@0:2:0"
    Option "AccelMethod" "None"
    Option "TearFree"    "true"
EndSection

Section "Screen"
    Identifier "intel"
    Device "intel"
EndSection

Section "Device"
    Identifier "nvidia"
    Driver "nvidia"
    BusID "PCI:1@0:0:0"
    Option "ConstrainCursor" "off"
EndSection

Section "Screen"
    Identifier "nvidia"
    Device "nvidia"
    Option "AllowEmptyInitialConfiguration" "on"
    Option "IgnoreDisplayDevices" "CRT"
EndSection

Xorg Monitor options

  • Thanks for this. I don't know what some numbers correspond to but I'll check them and the link as soon as I get back home :) – Celdor Dec 12 '19 at 14:43
  • I actually use the method you consider a "hack" by using a bash function for setting my own three monitors up. I do this on the odd occassion the settings get jumbled up when a TV is turned off at the wrong time. The bash function saves me from rebooting or remembering all the setup commands. I only used the above xorg configuration file when I had to. The link has some fascinating information though. – WinEunuuchs2Unix Dec 12 '19 at 23:42
  • In the end, maybe that hack is not too bad. It’s only one command anyway! Cheers! – Celdor Dec 13 '19 at 01:59