Load different xorg.conf for different users or sessions

Is there a way to setup up different user accounts or different sessions so that they will load different xorg.conf files?
I already have 2 separate xorg.conf files I would like to use, but I haven’t found a way to have User-A load xorg.conf-A and User-B load xorg.conf-B.
Is there any way to do this?

Thanks in advance.

I don’t think so because X is already running by the time you log in. However, I had a similar need to do this on my laptop, so I wrote a couple of small scripts to switch out the xorg.conf and restart X. Then I assigned the scripts to hotkeys in Compiz, so I can switch back and forth with a keystroke. For example, one script looks like this:

cp /etc/X11/xorg.conf.internal-only /etc/X11/xorg.conf
/etc/init.d/xdm stop
sleep 2
/etc/init.d/xdm start

In my case, I’m using KDE, but I think you can substitute gdm for kdm if you’re using GNOME. The sleep 2 is important because I noticed KDM fails to restart if you do it too quickly. Note also that this script needs to run as root. In order to do that without prompting for a password, you need to run it with sudo and add a line like this to your /etc/sudoers:

your_username ALL=NOPASSWD:/path/to/script/scriptname

Replace “your_username” and the path to the script as appropriate.

Alternatively, I believe that you can specify a particular xorg.conf at boot time by adding a kernel parameter to the GRUB line that starts your system. If memory serves, the parameter looks like XORG=path/to/xorg.cong, but I haven’t done this in awhile, so you might have to google a little to get the syntax right.

Thanks a lot for the response, using your idea I was able to write a script to swap out the xorg.conf files, but I’m having problems with the last few lines.
When I added the following lines:

/etc/init.d/xdm stop
sleep 2
/etc/init.d/xdm start

I got stuck in runlevel 3 and had to restart X from the command line, I also tried increasing the sleep time, but got the same result.

Any ideas?

That’s very weird. Stopping xdm should not change the runlevel from 5. Are you executing your script from within an X session?

BTW- I misspoke before when I mentioned changing the script to use “gdm” or “kdm”. I think “xdm” should cover both.

Yep, I was running it from within an Xsession.

After looking around for a few minutes I found a different want to restart X, namely just forcefully logging out the user by adding:

pkill KILL -u username

The odd thing is that even with this command I get sent back to runlevel 3, before it goes to the login screen, but at least it works :smiley:

Thanks for the help rhasselbaum.