«

»

Jan 18

LINUX: Fixing screen position running NVidia drivers

LINUX: Fixing screen position running NVidia drivers


Hello folks!

So lately I have been playing a lot with CentOS, and looks like I finally am on a stable setup, where I can compile all my stuff, opengl, cuda and TBB etc.

The problem that bothered me for a while was the setup of the screens, I had swapped monitor, meaning I had to go to the right  side in order to go in the left monitor, and swapping the monitors was not a solution due to a comples setup running with a shared monitor with two computers etc.

I was able to fix that with the nvidia-settings panel, unluckily the fix was not permanent, I tried a shitload of guides in order to fix the  problem, everyone suggested to use this command at runtime:

nvidia-settings --load-confing-only

But that was completely ignored for some weird reason I don;t know, so I had to do that with a script, I tried to mess around with the nvidia-settings command but no luck there, luckily I remebered a command I used ages ago on Ubuntu 10 to fix this very same problem, the command is xrandr, after a little googling on how to use the command I come out with few lines of code to fix my problem:

#!/bin/sh
xrandr --auto --output DVI-D-0 --right-of HDMI-0
xrandr --auto --output HDMI-0 --left-of DVI-D-0
xrandr --auto --output HDMI-0 --primary
echo ">>>> screens setupped properly ... I hope!"

The code first sets my second monitor on the right of my main and then the opposite, at the end I also set the HDMI monitor as primary.
Now you might wonder where I came out whit those names HDMI-0, DVI-D-0 etc. To get the names of your monitors is quite simple you just need to
run xrandr without arguments in the terminal and it will spit out the current plugged monitors.

</pre>
<pre>$ xrandr
Screen 0: minimum 8 x 8, current 3840 x 1080, maximum 16384 x 16384
VGA-0 disconnected (normal left inverted right x axis y axis)
DVI-D-0 connected 1920x1080+1920+0 (normal left inverted right x axis y axis) 531mm x 298mm
 1920x1080 60.0*+
 1680x1050 60.0 
 1600x900 60.0 
 1280x1024 75.0 60.0 
 1280x800 59.8 
 1280x720 60.0 
 1024x768 75.0 60.0 
 800x600 75.0 60.3 
 640x480 75.0 59.9 
HDMI-0 connected primary 1920x1080+0+0 (normal left inverted right x axis y axis) 477mm x 268mm
 1920x1080 60.0*+ 59.9 50.0 
 1680x1050 60.0 
 1600x900 60.0 
 1440x900 59.9 
 1280x1024 75.0 60.0 
 1280x800 59.8 
 1280x720 60.0 59.9 50.0 
 1152x864 75.0 
 1024x768 75.0 70.1 60.0 
 800x600 75.0 72.2 60.3 56.2 
 720x576 50.0 
 720x480 59.9 
 640x480 75.0 72.8 59.9</pre>

Once you know that you are golden and can make your script run.
Last two step where to run the script at start-up, and create and alias for the script since I have a complex setup with HDMI swithces etc which sometimes still
freaks out the monitors, so I run the script manually from terminal and all goes in the right place.

That’s it guys , happy Linux!

Leave a Reply