BASIC X-Windows
How to Start?
To start on the local screen, type in: startx (gnome) or startkde (kde)
How to Exit?
To get out of XWindows when a failure occurs press these 3 keys:
CtrlAltBackspace
Starting X Applications
XWindows is the Server/Client model – in reverse. The GUI is the server, the application is the client. Most Xwindows applications are local (Gnome or KDE local desktop). Sometimes we need to use an X client which needs to be run from another machine.
For example you may be logged in to marie (local machine - server) and want to run xterm from arthur (remote machine - client). If you just try to rlogin to arthur and then type xterme then most likely the command will fail with the message
Error: Can't open display:
This happens because xterm is trying to open a window on arthur but you are not on that machine. To fix this you must do two things:
- Tell arthur to display to your display (i.e. Marie console)
- Tell marie to accept input from arthur
This is accomplished by finding out the name of your display (that is the name of the terminal that marie is sending the display to).
A. In a terminal window of marie type:
echo DISPLAY
You should get a response like bw3.ma.utexas.edu:0.0; if you just get a blank line then type who and look for your username:
user1 /dev/pts1 Sep 17 13:16 (bw3.ma.utexas.ed)
The last item will be your display. It may be a name or IP address, If a name, use the uqulified hostname bw3.
B. In arthur type
export DISPLAY=bw3:0.0bash
or
setenv DISPLAY bw3:0.0csh
If you are at the console of a computer such as marie (ie. the computer itself is in front of you) then the display is called marie:0.0 (this also applies to the PCs). Otherwise, you are probably using a terminal, and you need to know its name. This will either be bwnn.ma.utexas.edu or colornn.ma.utexas.edu where nn is some number.
C. In marie type: xhost arthur
to which marie will reply: arthur being added to access control list.
D.You may then run any X client from arthur and display it on your monitor: xterm, xclock, twm, startx, startkde etc.
Here are some trouble shooting tips:
- Again, to get the heck out of XWindows when a failure occurs press these 3 keys: Ctrl + Alt + Backspace
- The XWindows files that you should be aware of and likely use:
/usr/X11R6/lib/X11/XF86Config = the configuration file you may spend time editing
SuperProbe = video clock probing
Xconfigurator = configuring X manually - system-config-display when using Fedora
drakconf or harddrake2 when using Mandrake
Customizing the Desktop Windows Manager (FWWM, Gnome or KDE for LINUX)
Fvwm uses three files: .fvwmrc, .xsession, and .Xdefaults. This section will give some ideas about how to customize these for yourself.
.XDefaults
This file contains information about your preferences for various applications. When you run a new application it looks in this file to see if there is anything it should use and then obeys it if possible. Each application has its own set of defaults and will use these if you don't set any. There is no single system wide .Xdefaults file so you need to create your own. The file is just a list of resources which are specified as strings of the form
appname*subname*subsubname...: value
By convention, the application name is the same as the program name, but with the first letter capitalized (e.g. Emacs). Here is a selection from mine:
Xterm*vt100*font: 10x20
Xterm*saveLines: 2000
Xterm*scrollBar: true
Emacs*Background: WhiteSmoke
Emacs*cursorColor: Red3
Emacs*menubar*Font: -adobe-helvetica-bold-r-normal--14-140-75-75-p-82-iso8859-1
Emacs*menu*Font: -adobe-helvetica-bold-r-normal--14-140-75-75-p-82-iso8859-1
Emacs*popup*Font: -adobe-helvetica-bold-r-normal--14-140-75-75-p-82-iso8859-1
Emacs*font: 9x15bold
Emacs*geometry: 80x35+180+0
Emacs*region*attributeBackground: lavender
Netscape*Navigator*geometry: 760x860-0+0
Most of this is fairly easy to work out. The first three lines ensure that all my terminal windows use the 10x20 font, with 2000 lines saved and a scroll bar. Most of the other settings make sense, except for the last emacs one. This (together with a setting in my .emacs file) means that when I select a region it is colored lavender.
If you don't want to create your own then you can copy ones from various people in the department by typing for example:
cp ~rpjudd/.Xdefaults ~/.Xdefaults
You should take care that you don't put contradictory information in this file, although if you do it will just get ignored. Another thing which you need to bear in mind is that some applications are very picky about the way you specify the resources. Emacs is one of these. If you look in my defaults file you will see that in some places there are periods instead of asterisks:
emacs*menubar.foreground: Lavender
emacs*menu*Foreground: Lavender
These two lines control different resources and each one has to be in this form. Thus, if at first it seems the resource you specify doesn't take effect then it may not be in the correct format.
Once you have created your defaults, you need to tell the X server about them. You can do this by either logging out and back in again, or with the command:
xrdb -load ~/.Xdefaults
For further information on which resources may be specified look in the man pages for X (towards the end) for general resources. For a particular application look in its man pages, and also in the defaults file (if it exists) for the application. These files are in the /usr/lib/X11/app-defaults/ directory.
.Xsession
This is the first file the X server looks at when starting your X environment. Its main job is some bookkeeping and to tell the server which windows manager to run. A typical .xsession file might look like
#!/bin/sh
if [ -f $HOME/.Xdefaults ]; then
xrdb -load $HOME/.Xdefaults
fi
# Put other commands here, eg xclock, xterm etc.
xclock -geometry +0+0 &
xterm -geometry +0-0 &
xterm -geometry 80x5+0+0 -C -ls &
fvwm
The first line says that this is a shell script to be executed by the shell. The if ... fi statement checks to see if you have a defaults file, and if you do it loads it, just as we saw above. The next lines start up some initial applications, and then run fvwm. Pay careful attention to the ampersands. Every line containing an application to be run, except the last, must end with an ampersand; the last line cannot end with one. This is so that all but one application runs in the background, while fvwm runs in the foreground. Thus to log out from your X Windows session you need to end fvwm with the exit command in the menu on button 1.
If you would rather end your X session by typing control-D or logout in a terminal window then swap the last two lines:
# Put other commands here, eg xclock, xterm etc.
xclock -geometry +0+0 &
xterm -geometry +0-0 &
fvwm &
xterm -T Logout -geometry 80x5+0+0 -C -ls
To log out you would use the window titled ``Logout''.
.fvwmrc
The system default file for this is /usr/lib/X11/fvwm/system.fvwmrc. It is a very long and at times complicated file, and there isn't enough space to go into it in detail here. Do not despair, however. The file itself contains copious comments explaining what is going on.
If you want to customize it then copy it to your home directory:
cp /usr/lib/X11/fvwm/system.fvwmrc ~/.fvwmrc
and then open the file in a text editor. Then read through the comments and experiment with changing things. Once you have made some changes, save the file and then restart fvwm to make the changes take effect. Rather than logging out and back in again, select the Exit Fvwm option in the menu on button 1. This will bring up a submenu; select Restart Fvwm. If the manager doesn't like the changes you made it will probably just ignore them.
We will discuss some parts of this file, to give you an idea. The first thing I changed were the fonts. I was going blind trying to read the menus so I changed the lines:
# Now the fonts - one for menus, another for window titles, another for icons
#Font -adobe-helvetica-medium-r-*-*-12-*-*-*-*-*-*-*
Font -*-times-medium-i-*-*-*-120-*-*-*-*-*-*
WindowFont -adobe-helvetica-bold-r-*-*-12-*-*-*-*-*-*-*
#IconFont -adobe-helvetica-medium-r-*-*-11-*-*-*-*-*-*-*
IconFont fixed
to give me larger fonts:
# Now the fonts - one for menus, another for window titles, another for icons
Font -adobe-helvetica-medium-r-*-*-18-*-*-*-*-*-*-*
WindowFont -adobe-helvetica-bold-r-normal--14-*-*-*-*-*-*-*
IconFont -adobe-helvetica-bold-r-normal--18-*-*-*-*-*-*-*
Note that the # symbol means that a comment follows. Everything after will be ignored.
For a (more than) complete list of fonts type the command xlsfonts | less in a terminal window.
The virtual desktop feature is controlled in these lines:
###########################################################################
# Set up the virtual desktop and pager
#set the desk top size in units of physical screen size
DeskTopSize 2x2
To make the desktop the same size as the screen change the last line to:
DeskTopSize 1x1
Obviously you may also increase the size of the desktop.
The next important item is the start up function. This is a list of applications to run when fvwm starts. You can put them all here instead of in your .xsession file if you want. The system file has everything commented out except for:
Function "InitFunction"
Module "I" GoodStuff
EndFunction
This line runs the GoodStuff module which we discussed in Section2.4. The settings for this are lower down in the file. You can put anything you like at this point. Here is mine:
# Stuff to do at start-up
Function "InitFunction"
Exec "I" xsetroot -bitmap misc/comet3.xbm &
Exec "I" exec emacs -geometry 90x49-0+0 -fn 9x15bold -iconic&
Exec "I" exec xclock -geometry 100x100+7+0 &
Exec "I" exec xload -geometry 100x100+7+110 &
Exec "I" exec xbiff -geometry +7+220 &
Exec "I" exec xterm -fn 10x20 -geometry 80x30-10-10 -T Pine -e pine &
Module "I" FvwmWinList
Module "I" FvwmPager 0 3
EndFunction
The first line changes my background to a pretty picture, the next five lines we have already discussed what they do, although the format is different here. When you add things you must take care to follow the same format. The last two lines start up a list of windows and the Pager, respectively. The window list is what I use instead of icons. It is simply a list which I can click on to switch to an application. The same list appears in the menu in button 3.
The last thing I will mention is how to write the menus which are bound to the mouse buttons. This is what the default looks like:
# This menu will fire up some very common utilities
Popup "Utilities"
Title "Utilities"
Exec "GNU Emacs" exec emacs &
Exec "Xterm" exec xterm &
Exec "Netscape" exec netscape &
Exec "Xfig" exec xfig &
Exec "Top" exec rxvt -T Top -n Top -e top &
Exec "Xman" exec xman &
Exec "Xmag" exec xmag &
Nop ""
Popup "Modules" Module-Popup
Nop ""
Popup "Exit" Quit-Verify
EndPopup
The format is similar to the start up function. Anything you add must follow this. Compare this with the menu on button 1. The option starting with Exec will run programs, while the Popup options bring up submenus. You can write your own submenus similarly. The Nop command just gives you a horizontal line.
Lower down in the file you will find the sections on binding commands and menus to the mouse, the function keys, and the title buttons, and on the defaults for the modules such as the Pager and GoodStuff.
I recommend that you copy the system file and then compare it with other people's. However this file is quite complicated and there are a lot of dependencies within it which are not obvious. You should not just copy someone else's file and use it, because it will probably not work. Mine, for instance, is set up for a particular screen size, and bits of it are incompatible with the standard one. Instead you should make small changes and see what effect they have, then keep going
Native X Windows System Configuration
How do you edit the monitor information running Fedora core or RedHat?
As root,Go to the directory /etc/X11/ and open xorg.conf if you are using Fedora or XF86Config for older versions of RedHat.
This is the file on the machine with Fedora( xorg.conf ) created by system-config-display
# Xorg configuration created by system-config-display
Section "ServerLayout"
Identifier "single head configuration"
Screen 0 "Screen0" 0 0
InputDevice "Mouse0" "CorePointer"
InputDevice "Keyboard0" "CoreKeyboard"
EndSection
Section "Files"
# RgbPath is the location of the RGB database. Note, this is the name of the
# file minus the extension (like ".txt" or ".db"). There is normally
# no need to change the default.
# Multiple FontPath entries are allowed (they are concatenated together)
# By default, Red Hat 6.0 and later now use a font server independent of
# the X server to render fonts.
RgbPath "/usr/X11R6/lib/X11/rgb"
FontPath "unix/:7100"
EndSection
Section "Module"
Load "dbe"
Load "extmod"
Load "fbdevhw"
Load "glx"
Load "record"
Load "freetype"
Load "type1"
Load "dri"
EndSection
Section "InputDevice"
# Specify which keyboard LEDs can be user-controlled (eg, with xset(1))
#Option"Xleds""1 2 3"
# To disable the XKEYBOARD extension, uncomment XkbDisable.
#Option"XkbDisable"
# To customise the XKB settings to suit your keyboard, modify the
# lines below (which are the defaults). For example, for a non-U.S.
# keyboard, you will probably want to use:
#Option"XkbModel""pc102"
# If you have a US Microsoft Natural keyboard, you can use:
#Option"XkbModel""microsoft"
#
# Then to change the language, change the Layout setting.
# For example, a german layout can be obtained with:
#Option"XkbLayout""de"
# or:
#Option"XkbLayout""de"
#Option"XkbVariant""nodeadkeys"
#
# If you'd like to switch the positions of your capslock and
# control keys, use:
#Option"XkbOptions""ctrl:swapcaps"
# Or if you just want both to be control, use:
#Option"XkbOptions""ctrl:nocaps"
#
Identifier "Keyboard0"
Driver "kbd"
Option "XkbModel" "pc105"
Option "XkbLayout" "us"
EndSection
Section "InputDevice"
Identifier "Mouse0"
Driver "mouse"
Option "Protocol" "IMPS/2"
Option "Device" "/dev/input/mice"
Option "ZAxisMapping" "4 5"
Option "Emulate3Buttons" "yes"
EndSection
Section "Monitor"
Identifier "Monitor0"
VendorName "Monitor Vendor"
ModelName "Hitachi CM500"
HorizSync 30.0 - 64.0
VertRefresh 50.0 - 100.0
Option "dpms"
EndSection
Section "Device"
Identifier "Videocard0"
Driver "ati"
VendorName "Videocard vendor"
BoardName "ATI Mach64"
EndSection
Section "Screen"
Identifier "Screen0"
Device "Videocard0"
Monitor "Monitor0"
DefaultDepth 8
SubSection "Display"
Viewport 0 0
Depth 16
Modes "800x600" "640x480"
EndSubSection
SubSection "Display"
Viewport 0 0
Depth 8
Modes "1024x768" "800x600" "640x480"
EndSubSection
EndSection
Section "DRI"
Group 0
Mode 0666
EndSection
Sample XF86Config file:
# XFree86 4 configuration created by pyxf86config
Section "ServerLayout"
Identifier "Default Layout"
Screen 0 "Screen0" 0 0
InputDevice "Mouse0" "CorePointer"
InputDevice "Keyboard0" "CoreKeyboard"
InputDevice "DevInputMice" "AlwaysCore"
EndSection
Section "Files"
# RgbPath is the location of the RGB database. Note, this is the name of the
# file minus the extension (like ".txt" or ".db"). There is normally
# no need to change the default.
# Multiple FontPath entries are allowed (they are concatenated together)
# By default, Red Hat 6.0 and later now use a font server independent of
# the X server to render fonts.
RgbPath "/usr/X11R6/lib/X11/rgb"
FontPath "unix/:7100"
EndSection
Section "Module"
Load "dbe"
Load "extmod"
Load "fbdevhw"
Load "glx"
Load "record"
Load "freetype"
Load "type1"
Load "dri"
EndSection
Section "InputDevice"
# Specify which keyboard LEDs can be user-controlled (eg, with xset(1))
#Option"Xleds""1 2 3"
# To disable the XKEYBOARD extension, uncomment XkbDisable.
#Option"XkbDisable"
# To customise the XKB settings to suit your keyboard, modify the
# lines below (which are the defaults). For example, for a non-U.S.
# keyboard, you will probably want to use:
#Option"XkbModel""pc102"
# If you have a US Microsoft Natural keyboard, you can use:
#Option"XkbModel""microsoft"
#
# Then to change the language, change the Layout setting.
# For example, a german layout can be obtained with:
#Option"XkbLayout""de"
# or:
#Option"XkbLayout""de"
#Option"XkbVariant""nodeadkeys"
#
# If you'd like to switch the positions of your capslock and
# control keys, use:
#Option"XkbOptions""ctrl:swapcaps"
# Or if you just want both to be control, use:
#Option"XkbOptions""ctrl:nocaps"
#
Identifier "Keyboard0"
Driver "keyboard"
Option "XkbRules" "xfree86"
Option "XkbModel" "pc105"
Option "XkbLayout" "us"
EndSection
Section "InputDevice"
Identifier "Mouse0"
Driver "mouse"
Option "Protocol" "PS/2"
Option "Device" "/dev/psaux"
Option "ZAxisMapping" "4 5"
Option "Emulate3Buttons" "yes"
EndSection
Section "InputDevice"
# If the normal CorePointer mouse is not a USB mouse then
# this input device can be used in AlwaysCore mode to let you
# also use USB mice at the same time.
Identifier "DevInputMice"
Driver "mouse"
Option "Protocol" "IMPS/2"
Option "Device" "/dev/input/mice"
Option "ZAxisMapping" "4 5"
Option "Emulate3Buttons" "no"
EndSection
Section "Monitor"
Identifier "Monitor0"
VendorName "Monitor Vendor"
ModelName "Hitachi CM500"
DisplaySize 270200
HorizSync 30.0 - 64.0
VertRefresh 50.0 - 100.0
Option "dpms"
EndSection
Section "Device"
Identifier "Videocard0"
Driver "i810"
VendorName "Videocard vendor"
BoardName "Intel 810"