12

I run this command to allow me to move windows between screens:

xrandr --auto

This magic command fixes my screen for me (before I run this my 2nd monitor is just an empty space where I can move my mouse). How can I make whatever this command does stick when I reboot? I'm more interested in fixing my configuration than just re-running this command, but I'm clueless as to how to make this happen.

I have 2 monitors, DFP 5 and DFP 6. Running xrandr results in this:

DFP1 disconnected (normal left inverted right x axis y axis)
DFP2 disconnected (normal left inverted right x axis y axis)
DFP3 disconnected (normal left inverted right x axis y axis)
DFP4 disconnected (normal left inverted right x axis y axis)
DFP5 connected 1680x1050+1680+0 (normal left inverted right x axis y axis) 474mm x 296mm
   1680x1050      60.0*+
   1400x1050      60.0  
   1280x1024      75.0     60.0  
   1440x900       60.0  
   1280x960       75.0     60.0  
   1280x800       75.0     60.0  
   1152x864       60.0     75.0  
   1280x768       75.0     60.0  
   1280x720       75.0     60.0  
   1024x768       75.0     60.0  
   800x600        75.0     60.3  
   640x480        75.0     59.9  
DFP6 connected 1680x1050+0+0 (normal left inverted right x axis y axis) 474mm x 296mm
   1680x1050      60.0*+
   1400x1050      60.0  
   1280x1024      75.0     60.0  
   1440x900       60.0  
   1280x960       75.0     60.0  
   1280x800       75.0     60.0  
   1152x864       60.0     75.0  
   1280x768       75.0     60.0  
   1280x720       75.0     60.0  
   1024x768       75.0     60.0  
   800x600        75.0     60.3  
   640x480        75.0     59.9  
CRT1 disconnected (normal left inverted right x axis y axis)

I have already set up DFP 6 to be right of DFP 5 using the Displays menu in debian. Here is my xorg.conf file:

Section "ServerLayout"
        Identifier     "aticonfig Layout"
        Screen      0  "aticonfig-Screen[0]-0" 0 0
EndSection

Section "Module"
EndSection

Section "Monitor"
        Identifier   "aticonfig-Monitor[0]-0"
        Option      "VendorName" "ATI Proprietary Driver"
        Option      "ModelName" "Generic Autodetecting Monitor"
        Option      "DPMS" "true"
EndSection

Section "Device"
        Identifier  "aticonfig-Device[0]-0"
        Driver      "fglrx"
        BusID       "PCI:4:0:0"
EndSection

Section "Screen"
        Identifier "aticonfig-Screen[0]-0"
        Device     "aticonfig-Device[0]-0"
        Monitor    "aticonfig-Monitor[0]-0"
        DefaultDepth     24
        SubSection "Display"
                Viewport   0 0
                Depth     24
                virtual 3360 1050
        EndSubSection
EndSection

It seems to be configured for everything to be one screen, and xrandr --auto somehow fixes it. Is there some way of taking a peek at what this command is doing to save the result to xorg.conf? How do you normally use xrandr to get the results to persist?

If I search for this I either get told to modify my xorg.conf file (which I don't know how to do because I don't know what xrandr --auto is actually doing) or instructions on how to run xrandr on startup, which I'm guessing isn't necessary, but I may be wrong.

quant
  • 4,161

5 Answers5

9

I created the following file:

/etc/X11/Xsession.d/45custom_xrandr-settings and placed this line into it:

xrandr --output DFP6 --primary

This had the effect of making the correct monitor the primary one, and it launches on login.

quant
  • 4,161
  • Note to self: BunsenLab (Lithium, derived from Debian 10), put my xrandr-line (as tested with ARandR Screen Layout Editor) in my home/.xsessionrc and it is called on each login. – Martin Zaske Oct 23 '21 at 22:32
4

Since this is the fglrx driver, you can use the aticonfig command to generate an xorg.conf file. From your xrandr output I'm guessing the command you need is this:

sudo aticonfig --initial=dual-head --screen-layout=left

If this doesn't give you what you want, aticonfig will automatically back up your xorg.conf file (with a .fglrx-x extension), so you can easily restore the original configuration.

If you don't have any luck with aticonfig, there is a GUI tool configuring xorg.conf called amdcccle (should be in the fglrx-control package).

Graeme
  • 34,027
  • 1
    er... Well I couldn't get aticonfig to work so I installed fglrx-control as you suggested. Now everytime I boot I get an extra copy of all my menu items. I don't know hot to explain it, but right now I've got Applications Menu 3 times across the top, next to 3 copies of the date and time and my on the right my name 3 times. Also there is a black bar between the menu items and where my desktop starts. Any ideas? – quant Apr 19 '14 at 21:30
  • Meanwhile my xorg.conf file has grown quite large... I've got 2 device, 2 screen and 4 monitor sections (I've got 1 graphics card and 2 actual monitors on my desk). – quant Apr 19 '14 at 21:32
  • @ArmanSchwarz, please add the new xorg.conf to the Q then ping me (just another comment here) and I will take a look. – Graeme Apr 19 '14 at 21:34
  • I just wiped my xorg.conf file back to what it was in the OP, so I don't know what it was. I've since restarted and I still have the same problem, so whatever the control centre did it's not an xorg.conf thing. The dual monitor setup works fine though, now it's just the issue of Gnome being completely destroyed. Is it possible that some settings elsewhere are being meddled with? I distinctly remember having a monitors.xml file which I modified, but it seems to be gone now... – quant Apr 19 '14 at 22:05
  • 1
    @ArmanSchwarz, sounds like Gnome has just got itself confused somehow. amdcccle shouldn't change anything other than xorg.conf (although it is hard to tell since it is closed source). Try doing your xrandr --auto again. If that doesn't fix it I would poke around inside Gnome settings (probably it has added the extra items and you can just remove them again). Failing that you could try resetting the Desktop - http://askubuntu.com/a/362579 (adding new user and logging in as them is another good way to non-destructively test if this will work). – Graeme Apr 19 '14 at 22:26
  • I tried wiping my gnome settings completely using rm -rf .gnome .gnome2 .gconf .gconfd .metacity (as per http://askubuntu.com/questions/56313/how-do-i-reset-gnome-to-the-defaults) and relogged but this seems to have had no effect. – quant Apr 19 '14 at 22:48
  • @ArmanSchwarz, hmmm. Please try a fresh user account in case the above didn't get everything. Also check for an xorg.conf.d directory in /etc. If amdcccle is badly behaved, it may alter /usr/share/X11/xorg.conf.d. You can list the files that are supposed to be there with dpkg -S xorg.conf.d. – Graeme Apr 19 '14 at 23:17
  • ok... so I've nuked my home directory and created a new account. Everything is great except my menu bar is on the wrong monitor. I can fix this by typing xrandr --output DFP6 --primary, but now I still don't know how to make this change permanent. I couldn't find a .xinitrc file either in my home directory nor in /etc/skel. – quant Apr 20 '14 at 01:09
  • but yeah all those other problems have disappeared! – quant Apr 20 '14 at 01:09
  • Ok... I spoke too soon. I thought I would instead try running that command you suggested in your answer again to fix the "primary monitor" problem. Now my machine takes 20-30 seconds longer to boot (after I log in, it just waits for 20-30 seconds before displaying icons/toolbar, no HDD activity). I tried creating a new user account but the lag persists. – quant Apr 20 '14 at 01:55
  • I removed an extra "Monitor" that aticonfig added in xorg.conf and now the lag seems to be gone.. – quant Apr 20 '14 at 02:12
  • @ArmanSchwarz, you can manually edit xorg.conf to make the other monitor primary, but probably the easiest thing to do is just to swap monitor connections and use --screen-layout=right. --screen-layout=left can be confusing for DEs, it is easier to add a acreen to the right. Also I recommend making sure Xinerama is enabled, this is the standard approach to multi-head (what xrandr uses). There are some more efficient but slightly hackish proprietary methods built into the driver. – Graeme Apr 20 '14 at 09:56
3

Run it with a boot script.

Part 1:

Create a directory for scripts... this can be anything and anywhere, just remember the location if you deviate so you can substitute it in.

mkdir ~/Scripts

You can use any text editor you are comfortable using for the next part

gedit ~/Scripts/setoutput.sh

Add these to the script #!/usr/bin/env sh xrandr --auto

I use "xrandr -s 1440x900" Save/close the file. Finish up by running the following commands:

chmod +x ~/Scripts/setoutput.sh
sudo ln -s ~/Scripts/setoutput.sh /etc/X11/Xsession.d/45setoutput
reboot

"reboot" may need replaced with "shutdown -r now"

When the system boots, your settings should have run, making them now persistent as long as the script exists.

Thanks in part to "xenopeek" for their post on Tue Nov 01, 2011 7:02 am at Linuxmint which provided directions for doing this with "xrandr --output VGA-0 --primary". Same base concept/script even if the command changed slightly.

Leptoid
  • 31
  • 3
2

How to make xrandr setting presistent

If you don't see your desired resolution in gnome settings:

Do these but change 1600 and 900 as you wish:

  1. cvt 1600 900

command output: # 1600x900 59.95 Hz (CVT 1.44M9) hsync: 55.99 kHz; pclk: 118.25 MHz Modeline "1600x900_60.00" 118.25 1600 1696 1856 2112 900 903 908 934 -hsync +vsync

  1. xrandr --newmode [output of line 1 after the word modeline]

command: xrandr --newmode "1600x900_60.00" 118.25 1600 1696 1856 2112 900 903 908 934 -hsync +vsync

  1. xrandr --addmode 1600x900_60.00
  2. sudo gedit /etc/X11/Xsession.d/45custom_xrandr-settings
  3. Add step 2 and 3 commands in file of step 4 and save
  4. Reboot and test.

As @quant said it loads after log in. And worked for me too. But different scenario. Thanks @quant.

Hardware:

  1. Display monitor: HP EliteDisplay E201
  2. Graphic: Xeon E3-1200 (CPU Based no graphic card)
Ali Samie
  • 121
-2
cvt 2560 1080 600
# copy output, minus 'Modeline'
xrandr --newmode "2560x1080_60.00"  230.00  2560 2720 2992 3424  1080 1083 1093 1120 -hsync +vsync
xrandr --addmode HDMI1 "2560x1080_60.00"
xrandr --output HDMI1 --mode 2560x1080_60.00 --rate 50.0
xrandr --output eDP1 --mode 1920x1080 --rate 60.0

check xrandr to see your HDMI number and eDP1 (which is my internal screen laptop) add these lines to sudo gedit /usr/sbin/lightdm-session

#Guide
#Purge xorg, xserver-* nvidia*
#Install online xorg and xserver-xorg
#Install nvidia-settings and nvidia-prime

#gnome-session-properties #unity --replace

  • also everything you're suggesting to add to the lightdm-session file is commented out. also, this assumes an nvidia driver, which wasn't called for in the OP. – Chaim Eliyah Jun 02 '21 at 20:53