2

What is the best place to add a mode with xrandr?

As of now, I added

xrandr --newmode "1344x744_60.00"   80.75  1344 1408 1544 1744  744 747 757 773 -hsync +vsync
xrandr --newmode "1344x768_60.00"   84.00  1344 1416 1552 1760  768 771 781 798 -hsync +vsync
xrandr --addmode DP-2 "1344x744_60.00" 
xrandr --addmode DP-2 "1344x768_60.00" 

to my ~/.bashrc, but this is obviously not the best place, as every time I launch a bash process it tries to add modes. So far, it only throws some errors (see below tl;dr), but it is harmless, I guess.

Perhaps .gnomerc is appropriate, although I guess if I start an xrdp session the mode may not be available.

Related:

  1. How to run scripts on start up?
  2. https://unix.stackexchange.com/questions/120291/how-to-get-external-monitor-resolution-set-by-xrandr-to-persist

EDIT: It seems ~/.xprofile may be a good place for these settings. I am not sure it works well with vino-server, which I need.

EDIT 2: This suggests using ~/.xinitrc. But it may be outdated.


TL;DR: Errors I get:

  1. When connecting from a text terminal (e.g., ssh)

       Can't open display
       Can't open display
       Can't open display
       Can't open display
    
  2. When starting a graphic terminal when the modes were already added

       X Error of failed request:  BadName (named color or font does not exist)
         Major opcode of failed request:  140 (RANDR)
         Minor opcode of failed request:  16 (RRCreateMode)
         Serial number of failed request:  27
         Current serial number in output stream:  27
       X Error of failed request:  BadName (named color or font does not exist)
         Major opcode of failed request:  140 (RANDR)
         Minor opcode of failed request:  16 (RRCreateMode)
         Serial number of failed request:  27
         Current serial number in output stream:  27
    

1 Answers1

0

If you are using X11, you can add the mode to a config file in /etc/X11/xorg.conf.d/. Name it something like 99-modes.conf.

Section "Modes"
   Identifier "modes"
   Modeline "1368x768"  85.86  1368 1440 1584 1800  768 769 772 795  -HSync +Vsync
EndSection

If the above doesn't work, you'll need to expand the config.

Section "Monitor"
   Identifier "monitor"
   Modeline "1368x768"  85.86  1368 1440 1584 1800  768 769 772 795  -HSync +Vsync
EndSection

Section "Device" Identifier "card" EndSection

Section "Screen" Identifier "screen" Device "card" Monitor "monitor" SubSection "Display" Modes "1368x768" EndSubSection EndSection

See also:

xiota
  • 5,038