37

I pressed something and accidentally swapped my two screens. My left one is actually considered as the right one, and vice versa. How can I swap them back?

Edit - Specifically, I'm using Gnome, though we might also want to keep this question generic.

Edit 2 - It appears that my driver isn't compatible with xrandr. I'm attaching log of /var/log/Xorg.0.log here

Jeff Schaller
  • 66,199
  • 35
  • 114
  • 250
ripper234
  • 31,063
  • 43
  • 82
  • 90

6 Answers6

49

Your desktop environment probably has a way, but you don't say which one you're using (if any).

If your display driver is compatible with the XRandR extension, which is the standard X.org method for managing display resolutions and arrangements, you can use the command-line utility xrandr. I think the proprietary NVidia driver bypasses XRandR, so if you're using it, you'll have to use a dedicated NVidia tool.

Run xrandr (with no argument) to see your monitor (screen) arrangement. You'll see lines like these:

DVI-0 connected 1600x1200+1600+0 (normal left inverted right x axis y axis) 408mm x 306mm
DVI-1 connected 1600x1200+0+0 (normal left inverted right x axis y axis) 408mm x 306mm

This example means that I have two monitors called DVI-0 and DVI-1, and DVI-1 is at the top left (position +0+0) while DVI-0 is to its right (position +1600+0). To swap them, I would run

xrandr --output DVI-0 --left-of DVI-1
Gilles 'SO- stop being evil'
  • 807,993
  • 194
  • 1,674
  • 2,175
  • I'm using Gnome. Having some problems with randr - http://pastebin.com/rZEjdN4B – ripper234 Apr 05 '11 at 06:34
  • @ripper234: Your display driver isn't compatible with XRandR. What display driver are you using (not just nvidia/ati/intel, but which driver: nv/nouveau/nvidia/radeon/radeonhd/fglrx/…)? If you're not sure, attach the contents of `/var/log/Xorg.0.log` to your question. – Gilles 'SO- stop being evil' Apr 05 '11 at 07:18
  • here's the log, thanks. http://pastebin.com/wpNutkwp – ripper234 Apr 05 '11 at 07:54
  • That swaps them around but now I can't scroll the mouse in the correct direction between them. When my mouse is on my right screen, when I scroll left, the mouse stops at the barrier of the right screen - it does not continue onto the left screen. – 8bitjunkie May 10 '18 at 11:31
7

I use Ubuntu 20.4, and pressed Win-P accidentally, and fuzzled around with the several options. To switch back to my original setting I used:

  1. press Win-P
  2. selected "Built in only"
  3. then pressed Win-P again
  4. selected "Join Displays"

If this keeps it in the wrong order, use "External only" first instead of "Built in Only"

Edo de Roo
  • 71
  • 1
  • 3
5

Ubuntu 18.10 here with GNOME 3.30.2. Just go to Settings > Devices > Displays.

The display arrangement can be rearranged, with simple drag-and-drop.

I had better experience doing this rather than adding xrandr --output DVI-0 --left-of DVI-1 to my /home/.profile.

Akhil
  • 151
  • 1
  • 2
2

I used the native Gnome Monitor Manager (from the System->Preferences menu) and it worked like a charm.

ripper234
  • 31,063
  • 43
  • 82
  • 90
1

I don't remember where I found this answer, but it works for me xrandr -o normal

0

I use this script for that purpose

#!/bin/bash

xrandr --prop | grep "[^dis]connected" | cut --delimiter=" " -f1> "$HOME/currentScreens.txt"
echo "Number of active screens:" $(< "$HOME/currentScreens.txt" wc -l)
if [ $(< "$HOME/currentScreens.txt" wc -l) -gt 1 ]; then 
   xrandr --auto && xrandr --output $(cat "$HOME/currentScreens.txt" | awk 'NR==1') --primary
   xrandr --auto && xrandr --output $(cat "$HOME/currentScreens.txt" | awk 'NR==2') --left-of $(cat "$HOME/currentScreens.txt" | awk 'NR==1')
else
   echo "Nothing to do"
fi
Ferroao
  • 284
  • 1
  • 2
  • 18