User Tools

Site Tools


linux:lxde_dual-monitor_setup

This is an old revision of the document!




As of July 2013, this fix seems to be outdated…. Not sure what walter did, but it seems to be fixed without using the lxdm configuration files.

Setup

Workstations with a dual-monitor setup have some issues with deciding which monitor to use as the primary monitor. This will cause some issues with some games, applications, and issues with screen alignment.

In order to fix these issues, Josh Kilmer (jkilmer) (srjek) has written some scripts to aid in the process of setup.

# Begin Josh Kilmer's (jkilmer)(srjek) dualmonitor script
xrandr --output DVI-I-3 --off  # Turn off secondary monitor to fix window snapping alignment issue
xrandr --auto  # For connected but disabled outputs, this will enable them using their preferred mode
xrandr --output DVI-I-3 --left-of DVI-I-2  # Set secondary monitor to be on the left (DVI-3)
xrandr --output DVI-I-2 --primary  # Set primary monitor to the on on the right (DVI-2)
# End Josh Kilmer's (jkilmer)(srjek) dualmonitor script

Please note that this has only been tested on the HP workstations running ArchLinux, and have not been extensively tested on single-monitor setups and the like.

Running at Login

Chase Lee 2013/04/27 02:19

In order to automate this process,(instead of making users do this themselves) we can put this script in the corresponding LXDM configurations files. The LXDM files are run at specific times during the login and logout process. Appending these commands will automatically setup the dual-monitor layout.

The following are copies of the modified LXDM configurations files as of May 13, 2013: Note that these settings should not be applied to single-monitor setups, as this may result in unintended results.

/etc/lxdm/PreShutdown | (Executed as root)

#!/bin/sh
#
# Note: this is a sample and will not be run as is.

/etc/lxdm/PostLogin | (Executed as logged-in user)

#!/bin/sh
#
# Note: this is a sample and will not be run as is.
#loltask > /dev/null &
thunar --daemon &
#if [ ! -d "/home/$USER/Steam" ]
#then
#	mkdir /home/$USER/Steam
#	echo "/home/$USER/Steam created on $HOSTNAME" >> /var/log/test  
#fi
#sudo /usr/local/bin/steamMount $USER

/etc/lxdm/PreReboot | (Executed as root)

#!/bin/sh
#
# Note: this is a sample and will not be run as is.

/etc/lxdm/PostLogout (Executed as logged-in user)

#!/bin/sh
#
# Note: this is a sample and will not be run as is.
if [ "$USER" == "acmguest" ]
then
	sudo /usr/local/sbin/guestd restart
fi
umount $HOME/.local/share/Steam
killall --user $USER -TERM
xsetroot -solid black
test -x /usr/bin/pax11publish && /usr/bin/pax11publish -r
# this makes sure lxdm is restarted if it crashes
if [ ! -z "$(pgrep lxdm)" ]
then
	 systemctl restart lxdm
fi

# this forces users t	o logout 
loginctl terminate-user user1 user2

# Begin Josh Kilmer's (jkilmer)(srjek) dualmonitor script
xrandr --output DVI-I-3 --off
# End Josh Kilmer's (jkilmer)(srjek) dualmonitor script

/etc/lxdm/PreLogin | (Executed as root)

#!/bin/sh
#
# Note: this is a sample and will not be run as is.
#!/bin/sh
#
# Note: this is a sample and will not be run as is.
#loltask > /dev/null &
#mount -B /opt/Steam /home/$USER/Steam
#if [ "$?" -ne "0" ]
#then
#	mkdir /home/$USER/Steam
#	mount -B /opt/Steam /home/$USER/Steam
#fi
#!/bin/sh
#
# Note: this is a sample and will not be run as is.
#!/bin/sh
#
# Note: this is a sample and will not be run as is.

mount -B /opt/Steamlocal $HOME/.local/share/Steam
chown -R $USER:users $HOME/.local/share/Steam
# Begin Josh Kilmer's (jkilmer)(srjek) dualmonitor script
xrandr --output DVI-I-3 --off
xrandr --auto
xrandr --output DVI-I-3 --left-of DVI-I-2
xrandr --output DVI-I-2 --primary
# End Josh Kilmer's (jkilmer)(srjek) dualmonitor script

/etc/lxdm/Xsession

#!/bin/bash

# use bash for "exec -l", howto run login shell by /bin/sh ?

if [ $# -eq 1 -a -n "$1" ]; then
	LXSESSION=$1
else
# default session
	LXSESSION=/usr/bin/startlxde
fi

[ -f /etc/profile ] && . /etc/profile
[ -f ~/.profile ] && . ~/.profile
[ -f /etc/xprofile ] && . /etc/xprofile
[ -f ~/.xprofile ] && . ~/.xprofile

if [ -f /etc/X11/xinit/xinitrc-common ]; then
# fedora
	. /etc/X11/xinit/xinitrc-common
	if ! [ -z "$XDG_SESSION_COOKIE" ]; then
		CK_XINIT_SESSION=
	elif [ -x /usr/bin/ck-launch-session -a -z "$CK_XINIT_SESSION" ]; then
		CK_XINIT_SESSION="/usr/bin/ck-launch-session"
	fi
	exec -l $SHELL -c "$CK_XINIT_SESSION \"$LXSESSION\""
elif [ -x /etc/X11/xinit/Xsession ]; then
# fedora
	exec /etc/X11/xinit/Xsession "$LXSESSION"
elif [ -x /etc/X11/Xsession ]; then
# mandriva, debian, ubuntu
	exec /etc/X11/Xsession "$LXSESSION"
elif [ -x /etc/X11/xinit/xinitrc ]; then
#suse
	export WINDOWMANAGER=$LXSESSION
	exec -l $SHELL -c /etc/X11/xinit/xinitrc
else
# unknown, user should custom /etc/lxdm/xinitrc self
	if [ -x /etc/lxdm/xinitrc ]; then
		. /etc/lxdm/xinitrc
	fi
	if ! [ -z "$XDG_SESSION_COOKIE" ]; then
		CK_XINIT_SESSION=
	elif [ -x /usr/bin/ck-launch-session ]; then
		CK_XINIT_SESSION="/usr/bin/ck-launch-session"
	fi
	exec -l $SHELL -c "$CK_XINIT_SESSION \"$LXSESSION\""
fi

/etc/lxdm/LoginReady | (Executed as root)

#!/bin/sh
#
# Note: this is a sample and will not be run as is.

Running at Login Notes

Note the only files that were modified/related to this fix is:

  • PostLogout
  • PreLogin

Other files are documented solely for the purpose of completeness.

Other improvements can possibly be made, but that's for another time and day…

Chase Lee 2013/04/27 02:19

linux/lxde_dual-monitor_setup.1455572689.txt.gz · Last modified: 2021/05/02 21:36 (external edit)