How to edit the xorg.conf file

How to do things, solutions, recipes, tutorials
Post Reply
Message
Author
User avatar
Flash
Official Dog Handler
Posts: 13071
Joined: Wed 04 May 2005, 16:04
Location: Arizona USA

How to edit the xorg.conf file

#1 Post by Flash »

[This is the contents of a post by npierce, copied and pasted here by Flash]
npierce wrote:
gerry wrote:Is it possible to edit /etc/X11/xorg.conf?
Yes, but with caution.

When editing most files, be they bash scripts, source code, configuration files, or whatever, we have become accustomed to the fact that comments are usually intended only for us human folk, and that the software will ignore them. But in some cases they are not ignored, and the interpretation of xorg.conf files by Puppy scripts is one of those cases.

Although the Xorg X server itself will ignore comments, some Puppy scripts, such as xwin, depend upon certain specific comments to identify the hardware that the xorg.conf file was created for and to locate specific lines in the file when they need to read or modify a setting. So when hand-editing an xorg.conf file, it is important not to disturb those specific comments.

(Before continuing, I should point out that I have been looking at Slacko 5.3.3. Puppy is always evolving, so I don't know if the information below is totally accurate for newer Puppies, as I've not dug into the latest versions of these scripts. If anyone is aware of recent changes to this information, please add to this thread.)

The most important of these comments usually appears at the end of the file in a line that begins with

Code: Select all

#PuppyHardwareProfile
One of the beauties of Puppy, is the ability to take your personal Puppy with you (on its CD, DVD, or flash drive) and boot it on any PC. Of course different PCs have different graphics chips and are connected to different monitors, either of which can have different capabilities than the hardware you first used with your Puppy. Puppy handles this by creating a custom xorg.conf file for each combination of graphics chip and monitor that you use with Puppy. It identifies the combination that each of these xorg.conf files was created for in the #PuppyHardwareProfile line.

When the xwin script is run (either automatically at boot time, or manually from the text console after "exiting to prompt"), it looks at that line in the current xorg.conf file, and probes your hardware to see if they match. If they match, Xorg is started using the current xorg.conf file. If they don't match, xwin saves the current xorg.conf by copying it to a file named "xorg.conf.<profile>" where "<profile>" is the current value found on the #PuppyHardwareProfile line. xwin then looks for an xorg.conf.<profile> file that does match, and copies that to xorg.conf before starting the Xorg server. If you are running your Puppy with a combination of graphics chip and monitor that you have not yet run it on, xwin will not find a match, so will run xorgwizard or xorgwizard-automatic to create a new xorg.conf file for this new hardware profile.

So the #PuppyHardwareProfile line is quite important. If you (or some script other than xorgwizard or xorgwizard-automatic) were to create a new xorg.conf file from scratch, and you didn't add a #PuppyHardwareProfile line to it, xwin would decide that it did not match your hardware, save it as "xorg.conf." (note the final dot), and go looking for an xorg.conf.<profile> that did match your hardware. So your new file, now renamed "xorg.conf.", would be ignored forever after, since xwin would not recognize a file named "xorg.conf." (again, note the final dot) as matching any hardware profile.


As you can see, if you boot your Puppy with different monitors or different graphics chips, any changes you make to the xorg.conf file for one profile will not be seen when you use hardware that matches another profile, unless you also make the same changes to the xorg.conf file for the other profile. This is good, since some changes you make may not be appropriate for other profiles. But you will need to edit the corresponding file for each profile where you do want your changes to be seen.


Another problem that sometimes arises is that when probing the hardware, the results returned for the graphics chip and monitor are occasionally different even when the graphics chip and monitor are unchanged. So, for instance, Puppy might make xorg.conf files for both a profile named "AcmeSuperlativeGraphicsCardAjaxFlatscreenMonitor" and a profile named only "AcmeSuperlativeGraphicsCard", if it once was unable to find the name of your monitor. In this case, if you make changes to xorg.conf when Puppy is using the first profile, but Puppy can't find the name of your monitor next time it boots, it will use the xorg.conf file for the other profile, or create a new one if it doesn't yet exist. Either way, the changes you made will not be seen, but might be seen again the next time you boot if Puppy is then able to find the name of your monitor.

(I do not know why this inconsistency exists. Puppy uses the ddcprobe utility for getting the names of your graphics chip and monitor. So the problem could be in that utility, in the hardware, or even in the design of the DDC protocol.)


While #PuppyHardwareProfile is the comment most responsible for determining whether or not the current xorg.conf gets over-written, there are a number of other comments used for identifying lines in xorg.conf so that they can be modified by various scripts. Here is a list of them:

#card0busid
#card0driver
#LOADDRI
#LOADGLX
#loadsynaptics
#METAMODES_0
#modes0modeline0
#monitor0prefmode
#monitor0usemodes
#mouse0protocol
#screen0modes
#scrollwheel
#serverlayoutsynaptics
#xkbmodel0
#xkbvariant0
#xkeymap0


Most of the remainder of this post provides a few details on those specific comments. Most Puppy users have no need for this level of detail. So, unless you plan on writing scripts that talk to xorg.conf, feel free to stop reading after this paragraph. If all you will be doing is hand-editing xorg.conf, all you need to know is that -- unless you have a good reason not to -- you should leave these comments in the file so that other scripts can find the lines in xorg.conf that they need to find.


A little background is in order here. The two scripts that create xorg.conf are xorgwizard and xorgwizard-automatic. The former is the old manual method, which asks you various questions about your screen resolution, mouse, and such. The latter is the new automatic method that configures some things automatically after probing the hardware, and lets recent Xorg X servers handle other things as they think best. The automatic method is only used for Xorg versions 1.7 and newer, and only if supported by the distro (as defined by DISTRO_XORG_AUTO in /etc/DISTRO_SPECS). It will only run on first boot if your /root/Startup/firstrun script disables it by commenting-out DISTRO_XORG_AUTO.

These two scripts have a somewhat different style of creating xorg.conf. This is probably an oversimplification, but basically they work like this: Each script starts with a basic file that already exists in /etc/X11/. The older xorgwizard script starts with a small file named xorg.conf0, then appends a lot of other configuration lines to it. The newer xorgwizard-automatic starts with a larger file named xorg.conf-auto-pc, and edits lines that are already in it.

(For use with versions of the Xorg X server older than 1.5, there is also a file named xorg.conf0XORG73, but, if needed, that simply gets copied over xorg.conf0 early in the script, before anything is appended to it.)

In the following list of specific comments, there is a "How initialized?" section for each comment. "Manual:" refers to how the line is created when xorgwizard is run, and "Auto:" refers to how the line is created when xorgwizard-automatic is run.

There is also a "How used?" section to indicate what scripts use this comment to locate the line for editing in xorg.conf. If there is no "How used?" section, then I don't know what script (if any) uses it. I've made no exhaustive search of Puppy scripts, but looked mostly at only xwin, xorgwizard, and xorgwizard-automatic. There may be scripts that use it other than those I have listed.


The specific comments - - -

#card0busid

Identifies BusID line in Section "Device" for "Card0".

How initialized?
Manual: unused
Auto: Exists in xorg.conf-auto-pc.


#card0driver

Identifies Driver line in Section "Device" for "Card0".

How initialized?
Manual: Written by xorgwizard when creating new xorg.conf
Auto: Exists in xorg.conf-auto-pc, but line is obsolete so commented-out.

How used?
Edited by xwin to set driver to "vesa" if current driver cannot be found.
Edited by xorgwizard to set Option "LinearAlloc" "6144" if driver is "intel" or "i810".


#LOADDRI

Identifies line to load or disable dri module in Section "Module".

How initialized?
Manual: Exists in xorg.conf0. Not in xorg.conf0XORG73.
Auto: Exists in xorg.conf-auto-pc.


#LOADGLX

Identifies line to load or disable GLX module in Section "Module".

How initialized?
Manual: Exists in xorg.conf0. Not in xorg.conf0XORG73.
Auto: Exists in xorg.conf-auto-pc.


#loadsynaptics

Identifies Load "synaptics" line in Section "Module".

How initialized?
Manual: Written by xorgwizard when creating new xorg.conf if a supported touchpad is detected.
Auto: Exists in xorg.conf-auto-pc; line is initially commented-out.

How used?
Edited by xorgwizard-automatic to un-comment-out the line if a supported touchpad is detected.


#METAMODES_0

Identifies Option "metamodes" line in Section "Screen" for "Screen0".

How initialized?
Manual: unused
Auto: Exists in xorg.conf-auto-pc, but line is commented-out.


#modes0modeline0

Identifies ModeLine line in Section "Modes" for "Modes0".

How initialized?
Manual: Written by xorgwizard when creating new xorg.conf, but line is initially empty.
Auto: Exists in xorg.conf-auto-pc, but line is initially empty.

How used?
Edited by xorgwizard if user chooses to use xvidtune to set a mode line.


#monitor0prefmode

Identifies Option "PreferredMode" line in Section "Monitor" for "Monitor0".

How initialized?
Manual: unused
Auto: Exists in xorg.conf-auto-pc, but line is initially commented-out.

How used?
Edited by xorgwizard-automatic with data from ddcprobe.


#monitor0usemodes

Identifies UseModes "Modes0" line in Section "Monitor" for "Monitor0".

How initialized?
Manual: Written by xorgwizard when creating new xorg.conf, but line is initially commented-out.
Auto: Exists in xorg.conf-auto-pc, but line is initially commented-out.


#mouse0protocol

Identifies Option "Protocol" line in Section "InputDevice" for "Mouse0".

How initialized?
Manual: Written by xorgwizard when creating new xorg.conf.
Auto: Exists in xorg.conf-auto-pc, assumes "IMPS/2" protocol.

How used?
Edited by xwin if mouse has changed.


#screen0modes

Identifies Modes line in Subsection "Display" in Section "Screen" for "Screen0".

How initialized?
Manual: unused
Auto: Exists in xorg.conf-auto-pc, initially commented-out.

How used?
Edited by xorgwizard-automatic to set screen modes based on data from ddcprobe.


#scrollwheel

Identifies Option "ZAxisMapping" line in Section "InputDevice" for "Mouse0".

How initialized?
Manual: Written by xorgwizard if using Option "Device" "/dev/mouse" or Option "Device" "/dev/input/mice". Line is commented-out unless value in /etc/mousebuttons is "5".
Auto: Exists in xorg.conf-auto-pc. Assumes buttons 4 ad 5.

How used?
Edited by xwin if line is commented-out, but searches for #Option\W\+"ZAxisMapping"\W\+"4 5", not #scrollwheel. Also, it doesn't write the "#scrollwheel" if it isn't there already.


#serverlayoutsynaptics

Identifies InputDevice "Synaptics Mouse" "AlwaysCore" line in Section "ServerLayout".

How initialized?
Manual: Written by xorgwizard when creating new xorg.conf if a supported touchpad is detected.
Auto: Exists in xorg.conf-auto-pc; line is initially commented-out.

How used?
Edited by xorgwizard-automatic to un-comment-out the line if a supported touchpad is detected.


#xkbmodel0

Identifies Option "XkbModel" line in Section "InputDevice" for Keyboard0.

How initialized?
Manual: Written by xorgwizard when creating new xorg.conf with data from keymap-set, but without the #xkbmodel0 comment.
Auto: Exists in xorg.conf-auto-pc, but without the #xkbmodel0 comment.
(I do not know what, if any, script adds the comment.)

How used?
Edited by xorgwizard-automatic with data from keymap-set.
This line is also edited by keymap-set. But that utility doesn't search for #xkbmodel0, it searches for '^[[:blank:]]*Option.*XkbModel'; nor does it write the #xkbmodel0 comment.
This line is also edited by the XkbConfigurationManager (a.k.a., XKB Configuration Manager, Advanced Xorg keyboard configuration) utility. But that utility doesn't search for #xkbmodel0, it searchers for XkbModel.


#xkbvariant0

Identifies Option "XkbVariant" line in Section "InputDevice" for Keyboard0.

Manual: Written by xorgwizard when creating new xorg.conf with data from keymap-set, but without the #xkbvariant0 comment.
Auto: Exists in xorg.conf-auto-pc, but without the #xkbvariant0 comment.
(I do not know what, if any, script adds the comment.)

How used?
Edited by xorgwizard-automatic with data from keymap-set.
This line is also edited by keymap-set. But that utility doesn't search for #xkbvariant0, it searches for '^[[:blank:]]*Option.*XkbVariant'; nor does it write the #xkbvariant0 comment.
This line is also edited by the XkbConfigurationManager (a.k.a., XKB Configuration Manager, Advanced Xorg keyboard configuration) utility. But that utility doesn't search for #xkbvariant0, it searchers for XkbVariant.


#xkeymap0

Identifies Option "XkbLayout" line in Section "InputDevice" for Keyboard0.

How initialized?
Manual: Written by xorgwizard when creating new xorg.conf with data from keymap-set.
Auto: Exists in xorg.conf-auto-pc. Initially set to "us".

How used?
Edited by xorgwizard-automatic with data from keymap-set.
Edited by xwin if its current value is not the desired value. (Desired value is based upon data in /etc/keymap, but not necessarily the same as what's in that file.)
This line is also written by keymap-set, but that utility doesn't search for #xkeymap0, it searches for '^[[:blank:]]*Option.*XkbLayout'.
This line is also edited by the XkbConfigurationManager (a.k.a., XKB Configuration Manager, Advanced Xorg keyboard configuration) utility. But that utility doesn't search for #xkeymap0, it searchers for XkbLayout.

User avatar
greengeek
Posts: 5789
Joined: Tue 20 Jul 2010, 09:34
Location: Republic of Novo Zelande

#2 Post by greengeek »

Thanks Flash and npierce. Very useful info. I've got a couple of Xorg.conf problems I need to get back to at some point and this fills in some of the gaps. It helps explain why my xorg.conf changes don't always stick.

User avatar
don570
Posts: 5528
Joined: Wed 10 Mar 2010, 19:58
Location: Ontario

#3 Post by don570 »

If you look inside the latest wacom driver made by charlie6
(found HERE )

there are suggestions to make an xorg.conf file
inside the folder /etc/X11/

I used these suggestions to make my xorg.conf file for Exprimo.

________________________________________________

anikin
Posts: 994
Joined: Thu 10 May 2012, 06:16

#4 Post by anikin »

Excellent explanation.
Thank you, npierce and Flash.

User avatar
`f00
Posts: 807
Joined: Thu 06 Nov 2008, 19:13
Location: the Western Reserve

#5 Post by `f00 »

Indeed, thanks go to Flash :idea: and npierce for a well-detailed bit on editing xorg.conf

Only smallish bit I have to add is relative to xvidtune..

In a few recent pups (precise and racy) I've had occasion to use xvidtune to fine-tune display placement and sizeº - the gui for xvidtune is fine for getting values for the modeline but is a bit confusing as to how to make the modeline functional from the xvidtune gui (test and save in particular).

I must have guessed at probably a dozen or so ways to make xvidtune work and finally hit on something that was effective in thrashing away at it.

After that exercise, it was much simpler to hand-edit xorg.conf for the modeline values (given in xvidtune) and go through a few re-Xs to test and tweak.

º - I could have used the monitor hwr control ui, but since the display offset/size is only an issue for me in racy and precise I went with the xvidtune -> custom modeline option for those pups.

Post Reply