Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

tl;dr

My laptop keeps forgetting the correct resolution of the external monitor attached to it. How can I make the configuration "stick"?

Details

I have a laptop running Linux Mint attached to an external ViewSonic monitor. I set it up to use the external monitor as a second screen (i.e. not mirrored). This worked fine for some weeks.

Suddenly, the laptop no longer recognized it as a ViewSonic, at which point it did not know its optimal resolution (1600 x 1200), only allowing a max of 1028 x 768.1 This did not work well at all with my laptop, which has 1920 x 1200 resolution.

After much frustration, I found this answer. It helped me to fix the problem, as follows (the output of the cvt command being the modeline which was used in the next command):

cvt 1600 1200
xrandr --newmode "1600x1200_60.00"  161.00  1600 1712 1880 2160  1200 1203 1207 1245 -hsync +vsync
xrandr --addmode VGA-1 1600x1200_60.00

This is exactly what I had been wishing I could do, but could not do through the GUI. (There are reasons why I still love the command-line...)

This once again worked well for a time. However, when I booted the computer today and signed in, I got a notification area popup with a string of errors about different attempted modes which weren't working, and the external monitor was switched off. I repeated the commands above, and it is working again.

I have an nVidia card. I tried installing the proprietary driver when things began to go awry, but at that point the external monitor was no longer recognized at all, so I am back to the open source driver. I do not have an Xorg.conf or an Xorg.conf.d, only an xorg.conf.failsafe.

I don't want to repeat these commands every time I boot the machine. Is there some way I can get this saved to my Xorg.conf or something? It's been a number of years since I've done much with X. Can anybody help me here?


1I have been unable to determine why this happened. My best guess is a problematic driver update.

share|improve this question
1  
What graphics card are you using? And if it is ATI/AMD or Nvidia are you using the proprietary driver or the open source one? Do you currently have an /etc/X11/corg.conf file or anything in /etc/X11/corg.conf.d? Id so, please edit your question and add the contents of those files. –  terdon Mar 18 at 23:02
    
Please edit your question to add extra info, it is hard to read and easy to miss in the comments. That said, yes, the xorg.conf is no longer needed, these things are now handled by udev. –  terdon Mar 18 at 23:51
    
Just looking at your question again and what I missed when I wrote my answer is that you have a laptop. What you might want to look into is writing a udev rule to call an script to do xrandr every time the monitor is plugged or unplugged, this will be much better id your computer is not always attached to the monitor. Otherwise, if you are happy having it set up in the same place all the time, Xorg.conf is the way to go. –  Graeme Mar 19 at 1:20

2 Answers 2

up vote 4 down vote accepted

I'm sure there's a better way, I think this is all handled by udev now but if you know that those commands will solve it, you could always just make them into a script:

#!/usr/bin/env bash
cvt 1600 1200
xrandr --newmode "1600x1200_60.00"  161.00  1600 1712 1880 2160  1200 1203 1207 1245 -hsync +vsync
xrandr --addmode VGA-1 1600x1200_60.00

Make it executable and then add it to your Desktop Environment's startup applications. This is probably the best choice if your DE provides you with the option.


If you can't do the above, as a dirty hack you could add them to your ~/.profile:

if [ ! -t 0 ] 
then
    cvt 1600 1200
    xrandr --newmode "1600x1200_60.00"  161.00  1600 1712 1880 2160  1200 1203 1207 1245 -hsync +vsync
    xrandr --addmode VGA-1 1600x1200_60.00
fi

The if [ ! -t 0 ] should ensure this is only run in the GUI and .profile is sourced by mint's login manager as I recall.

Now, you should also be able to use ~/.xsession but I've had issues with that being ignored. A lot of the older approaches are being replaced and I'm not sure what the state of the art way is.

share|improve this answer

If you are using the Nvidia proprietary driver then nvdia-settings should be the GUI tool to configure the Xorg.conf file. It should have its own package in Linux Mint, so installing would be as simple as:

sudo apt-get install nvidia-settings

This should put an icon in your menu somewhere, you can run it from there (though I'm not sure how you get it to have root permissions). From the command line I believe you can do:

sudo /usr/lib/nvidia/current/nvidia-settings

If you want to do command line, then nvidia-xconfig seems to be the tool to use (nvidia-xconfig package for me). Either way you will usually get better results with the proprietary driver if it is configured properly. These tools will at least generate a reasonable Xorg.conf file which you can then tweak either directly or through one of these programs.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.