DEV Community

Paul Preibisch
Paul Preibisch

Posted on • Edited on

Ensure Nvidia settings on restored on reboot - PopOs 22.04

I struggled NVidia on my Linux box for for years. On every reboot / disconnection of my Laptop, Nvidia settings would reset.

My Setup

2 display ports, and 1 HDMI port on my laptop = 4 displays.

The steps to have these set to specific orientations on startup are:

1) capture the current configuration from the xorg.conf file
2) write a script that writes the orientation/location/main monitor settings via nvidia-settings command line option
3) run the script at startup

Let's begin:

1) Capture the current configuration

Open the nvidia GUI through your OS, or via the command-line by typing: nvidia-settings.

Next, click "X Servier Display Configuration" set the orientation and location of each display, and the main display.

2) Grab the X Configuration settings

A popup appears, click "Show Preview"

Image description

Copy the preview text into an editor.

3) Search for nvidiaXineramaInfoOrder

We will set XineramaInfoOrder in the script below to this value

4) Search for metamodes. We will set CurrentMetaMode in the script below with this value

5) Write the Script:

So I created a script using the above attributes and the values from the xorg preview:

mkdir ~/bin
cd ~/bin
sudo nano nvidiaStartup.sh
Enter fullscreen mode Exit fullscreen mode

Now paste in the command:

nvidia-settings --assign <attributeName>="<your setting from xorg.conf"
Enter fullscreen mode Exit fullscreen mode

example:

#!/bin/bash
nvidia-settings --assign CurrentMetaMode="DP-0: nvidia-auto-select +0+0, HDMI-0: nvidia-auto-select +0+1050, DP-1: nvidia-auto-select +1920+1080, DP-3: nvidia-auto-select +4480+1080 {rotation=right}"
nvidia-settings --assign XineramaInfoOrder="DP-1"
Enter fullscreen mode Exit fullscreen mode

6) Set startup applications

Next, set the permissions of the script

sudo chmod u+x ~/bin/nvidiaStartup.sh
Enter fullscreen mode Exit fullscreen mode

To access start startup settings:

gnome-session-properties
Enter fullscreen mode Exit fullscreen mode

Image description

gnome-session-properties

press add

Image description

Now it will start up each time you load your OS.

To test it simply type

sh nvidiaStartup.sh
Enter fullscreen mode Exit fullscreen mode

Hope this helps!

Top comments (0)