Score:0

How to permanently save an xrandr configuration for a monitor even after reboot?

ar flag

I have a monitor. The hardware can support 1024x768 at 85Hz. But don't know why my lubuntu system does not detect this highest refresh rate for the resolution mentioned above.

As per this I did the following:

abhishek@abhishek:~$ cvt 1024 768 85
# 1024x768 84.89 Hz (CVT 0.79M3) hsync: 68.68 kHz; pclk: 94.50 MHz
Modeline "1024x768_85.00"   94.50  1024 1096 1200 1376  768 771 775 809 -hsync +vsync
abhishek@abhishek:~$ xrandr --newmode "1024x768_85.00" 94.50  1024 1096 1200 1376  768 771 775 809 -hsync +vsync
abhishek@abhishek:~$ xrandr | grep -e " connected [^(]" | sed -e "s/\([A-Z0-9]\+\) connected.*/\1/"
VGA-1
abhishek@abhishek:~$ xrandr --addmode VGA-1 1024x768_85.00
abhishek@abhishek:~$ xrandr
Screen 0: minimum 8 x 8, current 1024 x 768, maximum 32767 x 32767
VGA1 connected primary 1024x768+0+0 (normal left inverted right x axis y axis) 0mm x 0mm
   1024x768      60.00* 
   800x600       60.32    56.25  
   848x480       60.00  
   640x480       59.94  
   1024x768_85.00  84.89  
DVI-D-1 disconnected (normal left inverted right x axis y axis)
abhishek@abhishek:~$ 

So with the above I could add the new frequency temporarily. After reboot, this work is not remembered.

So as said I tried to create a .xprofile file as shown:

abhishek@abhishek:~$
abhishek@abhishek:~$ vi ~/.xprofile

I wrote the content...

This is the output:

abhishek@abhishek:~$ cat .xprofile
#!/bin/sh
randr --newmode "1024x768_85.00" 94.50  1024 1096 1200 1376  768 771 775 809 -hsync +vsync
xrandr --addmode VGA-1 1024x768_85.00
abhishek@abhishek:~$ 

It is exactly as said here to add undetected resolutions permanently...

I made the .xprofile file executable as well, but, the problem is after reboot, the configuration is lost...

I am cannot understand what is wrong... Please can anyone help me?

cn flag
are you using X? are you sure you are using a shell that uses that? no instructions on adding this to .bash_profile when using dash/bash? or to add .xprofile to something like .basj_profile or startup applications? what shell are you using ? the link shows FOUR methods and they expect you to pick the one suited for your setup :)
Abhishek Ghosh avatar
ar flag
@Rinzwind `abhishek@abhishek:~$ echo $0 /bin/bash abhishek@abhishek:~$`
Score:0
ar flag

This is how I came to a solution.

I took help from this article.

  1. We need to generate a modeline

We do so by going into terminal and typing “gtf x y r” where x is the horizontal resolution, y is the vertical resolution and r is the refresh rate (which is largely irrelevant since LCDs are the norm). So for example, mine was:

gtf 1024 768 85

Once you’ve executed the command you’ll be presented with something like this

abhishek@abhishek:~$ gtf 1024 768 85

  # 1024x768 @ 85.00 Hz (GTF) hsync: 68.60 kHz; pclk: 94.39 MHz
  Modeline "1024x768_85.00"  94.39  1024 1088 1200 1376  768 769 772 807  -HSync +Vsync

abhishek@abhishek:~$

We’re only interested in the second half, so make a note of everything from modeline onwards.

  1. We need to find the display interface name

In the terminal type: xrandr This will give you something along the lines of:

Screen 0: minimum 320 x 200, current 1024 x 768, maximum 8192 x 8192
VGA-1 connected primary 1024x768+0+0 (normal left inverted right x axis y axis) 0mm x 0mm
   1024x768      60.00*  
   800x600       60.32    56.25  
   848x480       60.00  
   640x480       59.94  
DVI-D-1 disconnected (normal left inverted right x axis y axis)
abhishek@abhishek:~$

The display interface name is the bit before ‘connected’ so in this case ‘VGA-1’. Make a note of yours.

  1. Creating the 10-monitor.conf

In order to create our spangly new resolution we need to create /usr/share/X11/xorg.conf.d/10-monitor.conf So in the terminal run:

sudo vi /usr/share/X11/xorg.conf.d/10-monitor.conf

This will open a blank text file, into which you want to paste the following:

Section "Monitor"
  Identifier "Monitor0"
  <INSERT MODELINE HERE>
EndSection
Section "Screen"
  Identifier "Screen0"
  Device "<INSERT DEVICE HERE>"
  Monitor "Monitor0"
  DefaultDepth 24
  SubSection "Display"
    Depth 24
    Modes "<INSERT MODENAME HERE>"
  EndSubSection
EndSection

The modename is the bit in quotes (so "1024x768_85" in our earlier example). You can add additional resolutions that already exist in the list xandr shows just by putting them in quotes and adding them to the end of the modes line.

So for reference, mine looks like this:

Section "Monitor"
  Identifier "Monitor0"
  Modeline "1024x768_85.00"  94.39  1024 1088 1200 1376  768 769 772 807  -HSync +Vsync
EndSection
Section "Screen"
  Identifier "Screen0"
  Device "VGA-1"
  Monitor "Monitor0"
  DefaultDepth 24
  SubSection "Display"
    Depth 24
    Modes "1024x768_85.00"
  EndSubSection
EndSection

And you’re done!

Once you’ve saved 10-monitor.conf in /usr/share/X11/xorg.conf.d/, restart your computer and you should have your brand new resolution available and set as default.


If you get a black screen on restarting, don’t panic, it probably means a typo or other syntax error of some description. While the computer’s on, hit ctrl+alt+F1 to go into a terminal and run:

sudo rm /usr/share/X11/xorg.conf.d/10-monitor.conf

Then restart and you’ll be back to defaults! Hope this saves someone some time and hair-pulling!


This indeed worked for me... And I put this setup of mine here, so that I can refer back to this later in the future... And if in case the link breaks, then there shall be a copy of the method in my answer full explanation as found in the source article...

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.