How to get external monitor resolution set by xrandr to persist
Solution 1
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.
Solution 2
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.
Solution 3
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:
- ArchWiki: Xorg
man xorg.conf
Related videos on Youtube
Amir
First experience with Linux in 2003. Saw someone else using Knoppix and was utterly enthralled. Later was sent a Dynabolic disk by a friend and was extremely excited by that. Sometime in 2004 or 2005 had my first experience with Ubuntu. Have tried out many, many other flavors of Linux since then but mostly stuck to Ubuntu where I had a choice. However, the latest I view the shopping lens of Unity as a symptom that Ubuntu is heading in the wrong direction. I have begun to look into other distros again. profile for Kazark on Stack Exchange, a network of free, community-driven Q&A sites http://stackexchange.com/users/flair/443137.png The birthdate I entered is farcical, as I prefer not to identify myself in any way online, but the age is in the ballpark.
Updated on September 18, 2022Comments
-
Amir over 1 year
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 of1028 x 768
.1 This did not work well at all with my laptop, which has1920 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 anXorg.conf.d
, only anxorg.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.
-
Admin about 10 yearsWhat 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. -
Admin about 10 yearsPlease 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.
-
Admin about 10 yearsJust 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.
-
-
PraveenMax about 7 yearsYou dont have to use cvt 1600 1200 since we already used its output in the next two lines.