5

I know this question has been asked before, and I know I've fixed this before, but I can't find anything that works for some reason.

Background: Every time I log in, my resolution resets to 1024x768, so I have to open up the nvidia settings and change it back to 1280x1024 every time.

Question: Is there a fix for this issue?

Additional Info:

  • Dell XPS 400
  • Xubuntu 12.10 (fresh install, not upgraded from 12.04)
  • Graphics Card: Nvidia GT430
  • GPU Driver: nvidia-current-updates
Josh Pinto
  • 8,089
ananaso
  • 4,080
  • 5
  • 32
  • 52

3 Answers3

2

The problem I think I was hitting was that the Nvidia x-server would load my preferred resolution (1280x1024), but then the settings manager would load its preferred option, which by default was 1024x768.

How I ended up solving this - in terminal:

  • sudo leafpad /etc/X11/xorg.conf

Scroll down, likely near or at the bottom, to where it says something like:

Section "Screen"
    Identifier     "Screen0"
    Device         "Device0"
    Monitor        "Monitor0"
    DefaultDepth    24
    Option         "Stereo" "0"
    Option         "nvidiaXineramaInfoOrder" "CRT-1"
    Option         "metamodes" "1280x1024_75 +0+0; nvidia-auto-select +0+0"
    SubSection     "Display"
        Depth       24
    EndSubSection
EndSection

The third option ("metamodes") is the resolution option. In that line, I removed the ; nvidia-auto-select +0+0. The line now looked like this:

Option         "metamodes" "1280x1024_75 +0+0"

This disallowed the settings manager to select the resolution it wanted and override xorg.conf, thus forcing the computer to use 1280x1024 by default.

ananaso
  • 4,080
  • 5
  • 32
  • 52
1

nvidia-settings

In nvidia-settings, under X Server Display Configuration, click Save to X Configuration File. If you've never done this before, it will complain about not being able to parse /etc/X11/xorg.conf. Just tell it "OK", it doesn't matter. You'll need to give it your password to elevate so that it can write to that file. Once you've done this, your resolution (and other changes in nvidia-settings) will persist through reboots.

Jim Salter
  • 4,383
0

I had the same problem. This is the solution that worked for me. I uploaded a whole working solution here
https://github.com/pangratt12345/automatic-monitor-readjustment
It seems that there are some bugs regarding /etc/X11/xorg.conf file.
Also it seems that no matter what the content of /etc/X11/xorg.conf file is, all Nvidia settings are overridden by native Linux settings stored in ~/.config/monitors.xml
This problem is also mentioned in this document in section - "The display settings I configured in nvidia-settings do not persist"
http://http.download.nvidia.com/XFree86/Linux-x86_64/565.57.01/README/commonproblems.html#settingsoverridden

So one approach might be to change the content of ~/.config/monitors.xml file
Another approach is to change screen resolution settings manually.

You can use 2 equivalent commands for this purpose:
nvidia-settings --assign CurrentMetaMode="HDMI-0: 1280x1024 +0+0"
xrandr --output HDMI-0 --mode 1280x1024

It is important to write correct cable interface into these commands
xrandr command shows which monitor/cable is currently used. For me it was HDMI-0. You may need to substitute HDMI-0 with DPY-3, DP-0, DVI-D-0, etc. depending on first element in xrandr output line corresponding to Your monitor
or can check the content of this folder
/sys/class/drm/

Then You can make an automatic script to be run after every startup of Linux
gnome-session-properties
or by creating file like nvidia-setup.desktop in this directory /home/{username}/.config/autostart/

[Desktop Entry]
Type=Application
Exec=nvidia-settings --assign CurrentMetaMode="HDMI-0: 1280x1024 +0+0"
Hidden=false
NoDisplay=false
X-GNOME-Autostart-enabled=true
Name=Monitor_settings_Readjustment

Or even better, you can create an udev callback to readjust nvidia screen settings properly every time specific monitor is plugged to PC

Can create udev rule like this 99-monitor-hotplug.rules in this folder /etc/udev/rules.d

KERNEL=="card[0-9]*", SUBSYSTEM=="drm", ACTION=="change", ENV{DISPLAY}=":1.0", ENV{XAUTHORITY}+="/run/user/1000/gdm/Xauthority", ENV{HOTPLUG}+="1", RUN+="/usr/sbin/hotplug.sh"

and callback function hotplug.sh in this folder /usr/sbin/

if [[ $(cat /sys/class/drm/card1-HDMI-A-1/status) == 'connected' ]]; then
    echo "monitor connected with HDMI";
    nvidia-settings --assign CurrentMetaMode="HDMI-0: 1280x1024 +0+0";
fi

When using udev monitor cable unplug/replug events then these 2 environment variables are important to be set in automatic script DISPLAY, XAUTHORITY
export DISPLAY=":$(find /tmp/.X11-unix/* | sed s#/tmp/.X11-unix/X##).0";
export XAUTHORITY="$(ps -C Xorg -f --no-header | sed -n "s/.*-auth //; s/ -[^ ].*//; p")";

More information about udev callbacks here https://stackoverflow.com/questions/5469828/how-to-create-a-callback-for-monitor-plugged-on-an-intel-graphics