3

I'm using ubuntu server with xmonad. I configure my dual monitor setup with xrandr but I can't get it to run on startup. My .xinitrc looks like this:

# WM
xmonad

# dual monitor
xrandr --output HDMI1 --auto
xrandr --output VGA1 --auto --left-of HDMI1

The settings are not being applied. How should I go about this?

2 Answers 2

4

ilia choly, See if this solution works better for you: How to force Multiple Monitors correct resolutions for LightDM?

It involves editing the /etc/lightdm/lightdm.conf to make the login screen (tested on Ubuntu 12.04) call a script. The file originally looks like this:

[SeatDefaults]
greeter-session=unity-greeter
user-session=ubuntu

Adding the below line makes it call the given script still before logging in:

display-setup-script=/usr/share/lightdmxrandr.sh

And this other line makes it call the given script after logging in:

session-setup-script=/usr/share/lightdmxrandr.sh

In this example, the lightdmxrandr.sh script serves for auto recognizing the resolution of the screen and of the external monitor, if there is one. Here's the script content in my case (I adapted just a little bit from the one on the link):

#!/bin/bash

# connected external output
XCOM0=`xrandr -q | egrep '(HDMI1|VGA1|DP1) connected' | egrep -o '(HDMI1|VGA1|DP1)'`
# command to set external desktop
XCOM1=`xrandr --output LVDS1 --primary --auto --output $XCOM0 --auto --right-of LVDS1`
# command to set normal desktop
XCOM2=`xrandr --output LVDS1 --primary --auto`
# if the external monitor is connected, then we tell XRANDR to set up an extended desktop
if [ -n "$XCOM0" ] || [ ! "$XCOM0" = "" ]; then echo $XCOM1
# if the external monitor is disconnected, then we tell XRANDR to output only to the laptop screen
else echo $XCOM2
fi

exit 0;

Save this file as lightdmxrand.sh Set as an executable file like this:

$ sudo chmod +x lightdmxrand.sh

Move it to /usr/share/ directory like this:

$ sudo mv lightdmxrand.sh /usr/share/lightdmxrandr.sh

Edit /etc/lightdm/lightdm.conf adding the given line to it:

display-setup-script=/usr/share/lightdmxrandr.sh

If you want this script to also run after the login, add:

session-setup-script=/usr/share/lightdmxrandr.sh

Hope it works for you!

1

Try it with an ampersand (&) behind xmonad. So it will be executed in the background. And the two xrandr commands can be executed.

# dual monitor
xrandr --output HDMI1 --auto
xrandr --output VGA1 --auto --left-of HDMI1

# WM
xmonad
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .