Ubuntu Forums ubuntu.com - launchpad.net - ubuntu help  

Go Back   Ubuntu Forums > The Ubuntu Forum Community > Forum Archive > Main Support Categories > Multimedia & Video
Register Reset Password Forum Help Forum Council Search Today's Posts Mark Forums Read

Hello, Unregistered You are browsing a READ only archive of the main support categories pre 4/21/2008. You will not be able to post or reply any threads in this section.

Multimedia & Video
Have multimedia question? ATI, Nvidia, Sound cards. Just ask here.

 
Thread Tools Display Modes
Old January 26th, 2008   #1
motin
Skinny Soy Caramel Ubuntu
 
Join Date: Mar 2006
Location: Stockholm, Sweden
Beans: 683
Ubuntu Studio Karmic Koala (testing)
HOWTO: YES! There IS an easy way of trying out Xorg.conf without reloading X

I feel that there is a massively wide-spread belief that display settings in X cannot applied without having to shut down all running applications.

All tutorials, howtos and forum replies that mentions reloading X configuration seem to recommend either pressing Ctrl + Alt + Backspace or Logging out and back in in order to restart X. Even if this is the most universally working method that requires the least amount of words to explain, THE CLASSIC Ctrl+Alt+Backspace METHOD IS VERY RISKY AND BY FAR THE QUICKEST NOR EASIEST WAY OF TESTING THE NEW CONFIGURATION. And, in case you are running Ubuntu Gutsy (or for that matter any modern distro using recent versions of X and Gnome) this quicker and safer way is easy as clicking "System -> Quit -> Switch User".

Some of the drawbacks with the classic recommendation:
  1. No graphical applications can be left running while trying out different display configurations
  2. In case the configuration doesn't work - the user is left into the hands of the rather unreliable X failsafe recovery software or even worse: no working graphical user interface at all
  3. It indicates that several X displays with separate configurations cannot run in parallell - and thus enforces the perception of that the generally used Linux display system is limited in nature and far behind the display systems of Mac OS X and/or Windows
  4. Especially, many new users that are wondering why their Fn + F4 laptop combination to switch video output modes are told that something like that just isn't possible with Linux computing.

Wouldn't you like to be able to:
  1. Try out Xorg.conf changes without having to shutdown any applications?
  2. Try out Xorg.conf changes with a smaller risk of being forced to cope with a permanent black screen or have to resort to recovery mode in order to restore a working Xorg.conf configuration?
  3. Not have to choose between for different configurations (for instance Extended desktop, Cloned output, S-Video, drivers, input devices etc) - but instead be able to hot-switch between them when you see fit?
  4. Run a stable non-compiz desktop session for work while being able to quickly and safely switch to a compiz-enabled session in order to play around, show friends and to other tasks for which it doesn't matter if X locks up?

Well, I am doing all of this without ever have had to resort to any complex command line voodoo. Everything is readily builtin and stable in Gutsy and called Fast user switching. Here's how:

Preparation
First we need to make it possible to login to a second X session. For this we need either to A. Add an extra user to the system, or B. Enable the option to allow multiple logins from the same user.

Alt A:
Follow these instructions: https://help.ubuntu.com/community/AddUsersHowto

Alt B:
Go to System -> Settings -> Login Window Preferences. Then untick the option "Disable multiple logins for a single user" and press Close.

Now you are set and ready to do any of the tasks I mentioned:

HOWTO: Try out xorg.conf changes without having to shutdown any applications and with a smaller risk of being forced to cope with a permanent black screen or have to resort to recovery mode in order to restore a working xorg.conf configuration

Example:
1. Make a backup copy of the current xorg.conf (ALWAYS TO THIS!):
Code:
sudo cp /etc/X11/xorg.conf /etc/X11/xorg.conf.known-to-work
2. Alter xorg.conf in any appropriate way*. (Maybe run "dpkg-reconfigure xserver-xorg" to fix that missing resolution?)
3. Choose System -> Quit -> Switch User

A new X session will start on a second display, and you can now switch between them using the combination Ctrl + Alt + F7 to F12. (Normally, the default X session will be available on Ctrl + Alt + F7, and the second you start will be on Ctrl + Alt + F9)

If you are thrown back into your original session when attempting this - your new xorg.conf probably has an error in it! Check /var/log/Xorg.*.log (usually Xorg.20.log for this second display), and don't forget to restore your backup configuration before rebooting!

* A word of caution:
Some configurations in xorg.conf have the potential to lock your whole system (not only X) up. A likely example being running two different X sessions with different Nvidia drivers (I've heard...). So use this methods only to try out modelines, changes to devices, resolutions and the likes and always go into maintenance mode (i.e. saving data and closing applications) before following these guidelines regardless.

HOWTO: Not have to choose between for different configurations (for instance Extended desktop, Cloned output, S-Video, drivers, input devices etc) - but instead be able to hot-switch between them when you see fit

If you use different X configuration files and want to use them in parallell - the trick is to start your first session with one of them, replace xorg.conf with an alternative version and then start a new X session.

I just wrote a bash+zenity script that automates this process. Check out the screen-shots to get an idea of what it does.

Download:
Save the following to a file named "switchxconf":
Code:
#!/bin/bash

# switchxconf - Easily swap between X configuration files based on 
#               multiple copies of xorg.conf with different file endings
#
# Preparation:
# Put your X configuration files in /etc/X11/ using different file endings
# in the following style: /etc/X11/xorg.conf.FileEnding /etc/X11/xorg.conf.AnotherFileEnding
#
# Usage: ./switchxconf CONFIGURATION
#
# Where CONFIGURATION is the file ending of the configuration file to switch to 
# (for instance "FileEnding")
#
# If CONFIGURATION is not specified, a dialog will popup and let you choose an 
# appropriate X configuration file
#
# Requirements:
# Xorg 7.3 or later. Zenity for the dialogue.
# This script has been tested on an Ubuntu Gutsy laptop with Intel 915 GM 
# Graphics chipset, using driver i810 and various display configurations (Xinerama, 
# Cloned CRT, S-Video etc)
#
# Acknowledements and version history:
# v20080126 - Original version with the basic configuration selection, activation 
#             and backup functionality - Fredrik Wollsén
#
# License GPL v3
#
# Feel free to provide feedback on this script here:
# http://ubuntuforums.org/showthread.php?p=4211618
#
# Suggestions for improvements:
#  - Detect Gnome or KDE and if KDE is active - use kdialog instead of zenity.
#  - Integrate with a tool to generate different X configurations (xorg-edit for instance)
#    and add the option to add a configuration using this tool.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
# GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
# IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

# Settings:

X11_CONF_DIR=/etc/X11/;
ALWAYS_CREATE_BACKUP=0; # Set to 1 to always create a backup xorg.conf in X11_CONF_DIR before each switch (Note: a temporary backup to /tmp is always performed)

# Variables

TS=`date +'%Y%m%d-%H%M%S'`;
ZENITY_CMD_TMP_FILE=/tmp/switchxconf.zenity.$$.$TS.tmp;
CURRENT_XORGCONF_TMP_FILE=/tmp/switchxconf.xorg.$$.$TS.tmp;
CONFIGURATION=$1;

# Identify requested configuration

if [ "$CONFIGURATION" == "" ]; then

	CONFIGURATIONS=`find $X11_CONF_DIR -maxdepth 1 -name 'xorg.conf.*' | sort -f \
	| sed -r 's/\/etc\/X11\/xorg\.conf\.(.*)/"" "\\1"/g' | tee $ZENITY_CMD_TMP_FILE`;

	if [ "$CONFIGURATIONS" == "" ]; then

		echo "No available configurations were found. Please put your xorg.conf"
		echo "files in $X11_CONF_DIR with an additional file ending, for instance"
		echo "${X11_CONF_DIR}xorg.conf.Cloned-setup or ${X11_CONF_DIR}xorg.conf.Intel-test."

		exit 1;

	fi

	echo Found configurations: $CONFIGURATIONS;

	# Generate zenity selection script
	echo zenity --list --radiolist \
	 --title \"Change Display Mode\" \
	 --text \"Choose what configuration you want to activate.\" \
	 --height=300 \
	 --column \"\" --column \"File\" `cat $ZENITY_CMD_TMP_FILE` > $ZENITY_CMD_TMP_FILE;
	
	CONFIGURATION=`source $ZENITY_CMD_TMP_FILE`;

	# Remove tmpfile
	rm $ZENITY_CMD_TMP_FILE;

fi

if [ "$CONFIGURATION" == "" ]; then

	echo No configuration file chosen. Assumed program abort. Exiting...
	exit 0;

fi

echo Making sure that there is a backup of a working X configuration file...

BACKUPS=`find $X11_CONF_DIR -maxdepth 1 -name 'xorg.conf.known-to-work*'`;

if [ "$BACKUPS" == "" -o $ALWAYS_CREATE_BACKUP -gt 0 ] ; then

	echo None found - Creating backup...
	gksudo cp ${X11_CONF_DIR}xorg.conf ${X11_CONF_DIR}xorg.conf.known-to-work-$TS;
	echo Done!

else

	echo "Good - Found backup(s): $BACKUPS";

fi

# Always perform a backup of the current file to /tmp
cp ${X11_CONF_DIR}xorg.conf $CURRENT_XORGCONF_TMP_FILE;

echo Activating chosen configuration: \"$CONFIGURATION\" now;

gksudo cp ${X11_CONF_DIR}xorg.conf.$CONFIGURATION ${X11_CONF_DIR}xorg.conf;

APPLY_METHOD=`zenity --list --radiolist \
         --title "Active X Configuration changed!" \
         --text "How do you want to apply the new configuration?\n\nRemember that regardless of what method you \
choose here,\nthe newly activated configuration file will be the one\nused for the default session after a reboot. 
"\
	 --height=400 \
         --column "" --column "" --column "Choice" \
	"TRUE" 1 "Start a new X session in parallell (recommended)" \
	"" 2 "Log out the current session" \
	"" 3 "Kill X (forcingly shuts down the graphical interface)" \
	"" 4 "Do nothing right now (just leave as default boot option)"`;

#	"" 3 "Restart GNOME Display Manager (shuts down the graphical interface)" \

case "$APPLY_METHOD" in
      1          ) zenity --info --text "To return to this session, use one of the Ctrl + \
Alt + F7 to F12 key combinations (Try them one at a time until you arrive back to this session).\n\nRemember that you either need a second user to login with or enabled multiple logins for the same user (done in System -> Settings -> Login Window Preferences) in order to actually login using the new configuration.\n\nTip: If the newly activated configuration doesn't work at all - be sure to return to this session (before rebooting!) and either run \
this script again, choosing a working configuration, or restore your last configuration file found in \
$CURRENT_XORGCONF_TMP_FILE"\
 && gdmflexiserver;;
      2          ) gnome-session-save --kill --silent;;
      3          ) gksudo pkill Xorg;;
      4          ) echo "Doing nothing but exiting script...";;
      *          ) gksudo cp $CURRENT_XORGCONF_TMP_FILE ${X11_CONF_DIR}xorg.conf \
		   && zenity --info --text "Switch cancelled. Your previous X configuration has been restored.";;
esac

#      3          ) gksudo invoke-rc.d gdm restart;;   # Commenting because while it shuts down gdm, neither this nor "gksudo /etc/init.d/gdm restart" would bring gdm back up afterwards

exit 0;
And save the following to a file named "switchxconf.desktop":
Code:
[Desktop Entry]
Encoding=UTF-8
Version=1.0
Type=Application
Terminal=false
Exec=switchxconf
Name=Switch X Configuration
Icon=/usr/share/pixmaps/gnome-background.png
Categories=Application;System;
Hidden=false
Installation:
Code:
chmod +x switchxconf;
sudo cp switchxconf /usr/bin/;
sudo cp switchxconf.desktop /usr/share/applications/;
sudo apt-get install zenity;
Now, you should be able to click Applications -> System Tools ->Switch X Configuration in the GNOME Menu (you might need to logout and back in for it to show).

You can also run "switchxconf" in a terminal.

Uninstallation:
Code:
rm /usr/bin/switchxconf;
rm /usr/share/applications/switchxconf.desktop;
Attached is my collection of X configuration files (attached). They are mostly for Intel 915GM cards, but should work with other Intel cards (like 945). All but the S-video versions are prepared to work with the Wiimote.
Thanks a million to featherking for his original tutorial on creating these config files.

HOWTO: Make use of RandR 1.2 - or the ability to stick with one X configuration and dynamically add or remove screens and change display setups dynamically

Basically if Gutsy is your first installation or you have run "dpkg-reconfigure xserver-xorg" using Gutsy - you will have a RandR 1.2 setup. Verify this by running "xrandr" in a terminal. If you get something like:

Code:
$ xrandr
Screen 0: minimum 320 x 200, current 1280 x 800, maximum 2048 x 2048
VGA disconnected (normal left inverted right)
LVDS connected 1280x800+0+0 (normal left inverted right) 331mm x 207mm
   1280x800_60.00   60.0*+
   1280x800       60.0 +   60.0  
   1280x768       60.0  
   1024x768       60.0  
   800x600        60.3  
   640x480        59.9  
TV disconnected (normal left inverted right)
... then RandR 1.2 is active (it detects your output ports and whether or not there are screens attached).

Here are some commands to get you started if you use a RandR based configuration (one is attached btw):

Turn on VGA-connected monitor output:
Code:
xrandr --output VGA --auto
Turn off VGA-connected monitor output:
Code:
xrandr --output VGA --off
Turn on Laptop monitor output:
Code:
xrandr --output LVDS --auto
Turn off Laptop monitor output:
Code:
xrandr --output LVDS --off
Change resolution on VGA-connected monitor:
Code:
xrandr --output VGA --mode "1024x768"
Setup extended desktop on VGA-connected monitor:
Code:
xrandr --output VGA --below LVDS
(You need to go with "below" because of a limit of a maximum 2048x2048 total resolution and still be able to use desktop effects)

Turn on S-Video (PAL color example):
Code:
xrandr --output TV --set TV_FORMAT PAL
Code:
xrandr --output TV --auto
Note: If the GNOME Panels are on the wrong screen, you can drag them to the correct screen. Where these show up after login is sadly yet not configurable. Hopefully the next version of GNOME will make it possible to take this into account on login.
Attached Thumbnails
Click image for larger version

Name:	2. Apply X Configuration.png
Views:	293
Size:	33.6 KB
ID:	57966   Click image for larger version

Name:	3. Information before starting new X session.png
Views:	263
Size:	41.2 KB
ID:	57967   Click image for larger version

Name:	1. Change Display Mode.png
Views:	341
Size:	29.2 KB
ID:	57965  
Attached Files
File Type: gz xorg.confs-intel915gm.tar.gz (2.9 KB, 133 views)

Last edited by motin; February 13th, 2008 at 01:10 PM.. Reason: Updated misc wordings
motin is offline   Reply With Quote
Old January 27th, 2008   #2
Cyclops_
A Carafe of Ubuntu
 
Join Date: Apr 2006
Beans: 93
Re: HOWTO: YES! There IS an easy, safe way of reloading Xorg.conf without shutting do

Say... I don't have the "New Login" under Applications > System Tools. Is there something I need to install for it?

Thanks
__________________
Cy
Cyclops_ is offline   Reply With Quote
Old January 29th, 2008   #3
motin
Skinny Soy Caramel Ubuntu
 
Join Date: Mar 2006
Location: Stockholm, Sweden
Beans: 683
Ubuntu Studio Karmic Koala (testing)
Re: HOWTO: YES! There IS an easy, safe way of reloading Xorg.conf without shutting do

Quote:
Originally Posted by Cyclops_ View Post
Say... I don't have the "New Login" under Applications > System Tools. Is there something I need to install for it?

Thanks
I have translated that from the Swedish translation and wasn't sure it was 100% correct. But, according to this thread, it is... and should be available in a default Gutsy installation.

I am not sure what might be the issue. What you can do is use the script above as it will launch the New login command for you (gdmflexiserver).
motin is offline   Reply With Quote
Old January 29th, 2008   #4
archivator
Just Give Me the Beans!
 
Join Date: Feb 2007
Beans: 62
Re: HOWTO: YES! There IS an easy, safe way of reloading Xorg.conf without shutting do

Right click on the Applications menu -> Edit Menus -> System Tools -> make sure New Login has a tick in front of it.
archivator is offline   Reply With Quote
Old January 29th, 2008   #5
eye208
Day Old Decaf
 
Join Date: Nov 2006
Beans: 1,134
Re: HOWTO: YES! There IS an easy, safe way of reloading Xorg.conf without shutting do

Quote:
Originally Posted by motin View Post
THIS IS NO LONGER THE ONLY WAY IN CASE YOU ARE RUNNING UBUNTU GUTSY or for that matter any modern distro using recent versions of X and Gnome.
Running several instances of X has been possible for as long as I remember. All you need to do is switch to a tty console, then run e.g. "startx -- :1".
eye208 is offline   Reply With Quote
Old January 29th, 2008   #6
motin
Skinny Soy Caramel Ubuntu
 
Join Date: Mar 2006
Location: Stockholm, Sweden
Beans: 683
Ubuntu Studio Karmic Koala (testing)
Re: HOWTO: YES! There IS an easy, safe way of reloading Xorg.conf without shutting do

Quote:
Originally Posted by eye208 View Post
Running several instances of X has been possible for as long as I remember. All you need to do is switch to a tty console, then run e.g. "startx -- :1".
Yes, but when referring to easy I meant a stable method that doesn't involve switching to a tty console. Now it's plug-n-play

EDIT: I reworded that sentence in the OP now. Thanks for pointing it out.

Last edited by motin; January 29th, 2008 at 07:11 PM..
motin is offline   Reply With Quote
Old January 29th, 2008   #7
eye208
Day Old Decaf
 
Join Date: Nov 2006
Beans: 1,134
Re: HOWTO: YES! There IS an easy, safe way of reloading Xorg.conf without shutting do

Quote:
Originally Posted by motin View Post
Yes, but when referring to easy I meant a stable method that doesn't involve switching to a tty console. Now it's plug-n-play
There is nothing in your method that makes testing X.org configurations easier or safer than before. You wrote:
Quote:
Try out xorg.conf changes without having to shutdown any applications and without the risk of being forced to cope with a permanent black screen or have to resort to rescue mode in order to restore a working xorg.conf configuration
You are giving people a false sense of security encouraging them to make xorg.conf changes without going into maintenance mode, i.e. without saving data and closing applications. If someone tests a display driver this way, he may not be able to go back to the first instance of X in case of display corruption or freezing. Recovering the original xorg.conf file will still require him to use the recovery console. But unlike the conventional method, he may also have lost some application data due to the inevitable system restart.

The current X.org has not been designed to run with multiple configurations at once. The fact that you can trick it into doing so does not mean it's safe.
eye208 is offline   Reply With Quote
Old February 13th, 2008   #8
motin
Skinny Soy Caramel Ubuntu
 
Join Date: Mar 2006
Location: Stockholm, Sweden
Beans: 683
Ubuntu Studio Karmic Koala (testing)
Re: HOWTO: YES! There IS an easy, safe way of reloading Xorg.conf without shutting do

Quote:
Originally Posted by eye208 View Post
There is nothing in your method that makes testing X.org configurations easier or safer than before. You wrote:

You are giving people a false sense of security encouraging them to make xorg.conf changes without going into maintenance mode, i.e. without saving data and closing applications. If someone tests a display driver this way, he may not be able to go back to the first instance of X in case of display corruption or freezing. Recovering the original xorg.conf file will still require him to use the recovery console. But unlike the conventional method, he may also have lost some application data due to the inevitable system restart.

The current X.org has not been designed to run with multiple configurations at once. The fact that you can trick it into doing so does not mean it's safe.
Very true. I have updated my post accordingly. Thanks, man!
motin is offline   Reply With Quote
Old January 29th, 2008   #9
motin
Skinny Soy Caramel Ubuntu
 
Join Date: Mar 2006
Location: Stockholm, Sweden
Beans: 683
Ubuntu Studio Karmic Koala (testing)
Re: HOWTO: YES! There IS an easy, safe way of reloading Xorg.conf without shutting do

Quote:
Originally Posted by Cyclops_ View Post
Say... I don't have the "New Login" under Applications > System Tools. Is there something I need to install for it?

Thanks
Quote:
Originally Posted by archivator View Post
Right click on the Applications menu -> Edit Menus -> System Tools -> make sure New Login has a tick in front of it.
Yeah I just realized that 1. archivator is correct - the choice isn't visible by default and 2. I was blind... there is a much easier way for which I have updated the tutorial: System -> Quit -> Switch User

Cheers!
motin is offline   Reply With Quote
Old April 4th, 2008   #10
Ketahazure
First Cup of Ubuntu
 
Join Date: Nov 2007
Beans: 6
Re: HOWTO: YES! There IS an easy, safe way of reloading Xorg.conf without shutting do

Great How-to, thanks! dpkg-reconfigure xserver-xorg was one of the commands i had trouble with.
Ketahazure is offline   Reply With Quote

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 11:05 PM.


vBulletin ©2000 - 2010, Jelsoft Enterprises Ltd. Ubuntu Logo, Ubuntu and Canonical © Canonical Ltd. Tango Icons © Tango Desktop Project. lingonberry