Softpanorama
(slightly skeptical) Open Source Software Educational Society

May the source be with you, but remember the KISS principle ;-)

Softpanorama Search

Useful X11 Tips

News Recommended Links Minitutorial Architecture X display manager XDMCP Troubleshooting
Configuration Fonts in X Exporting_display Xdefaults Using xauth    
vnc Cygwin/X X11 security Tips History Humor Etc

News

[Oct 12, 2006] BigAdmin - Submitted Tech Tip Redefining Escape Sequences Generated by Function Keys Using xterm by Phillip Wu, September 2006

Often it is necessary to change the escape sequences generated by xterm when function keys are pressed, in order to match what an application expects. For example, this is very common for Oracle applications. Here's a way to do this.

Start xterm as follows where the escape sequences for F1, F2, and F3 have been redefined. Also, start an application called appl.sh.

/usr/openwin/bin/xterm  -name appl -xrm \
'/*
 F1=Exit
 F2=Clear Record
 F3=Back Tab
*/
runlod*VT100.translations:   #override\n\
        <Key>F1:        string(0x1b) string("OS")\n\
        <Key>F2:        string(0x1b) string("[32~")\n\
        <Key>F3:        string(0x1b) string("OP") string(0xff09)' \
-e  appl.sh

fonts

Xwindows on Solaris Tips

Copy and zip your favourite MS fonts  from the nearest Windows box, a good start would be Arial, and Verdana, this will improve the look of most websites considerably.

On  the Solaris box unzip the fonts into a temporary directory, using the -L switch ensures that the font names are lower case.
 

#unzip -L arial.zip

in the same directory run

#sdtfontadm

This is a GUI tool, so just select the new fonts and click Install, the fonts will be installed in $HOME/fontadm_fonts. Earlier versions of this tool were reported to be unreliable, but the Sol9 version has worked everytime for me.

Contents

  1. What is the X Window System?
     
  2. Window managers available
     
  3. How do I configure my X Windows Session? (ie. change default window manager, set up startup applications, ...)
     
  4. Now how do I change the default settings of my favorite applications?
     
  5. But how do I find out the resources available for customizing an application?
     
  6. Can I change the resources of an application that is already running?
     
  7. Can I set resources using command line options?
     
  8. How do I find out which colors are availables?
     
  9. How can I a choose fonts for my applications?
     
  10. How do I remap the keys on my keyboard?
     
  11. How can I change the keyboard or the mouse cursor speed?
     
  12. Description of common error messages
     
  13. X11 FAQ

 

What is the X Window System?

The X Window System is a client-server windowing system that works independently from an operating system. It was originally developed by Project Athena at MIT and is now owned and didtributed by a non profit organization called the X Consortium Inc.

In the X Windows world, the hardware through which you communicate with your programs (ie. the keyboard, the mouse, screens, ...) is called a display, and is controlled by a piece of software called an X Window Server. To establish communication with a person, a program (called a client) connects itself to this server through some comunication channel.

Client software talks with the server through a predefined set of message formats called the X Window System Protocol. Messages sent by a client are called requests, since they request actions by the server or information from it. Messages sent by the server to its clients are either responses that provide the requested information or feedback on the success or failure of the requested action, or events that tell the client that some event it might be interested in has taken place.

In conclusion, the X Window System is a windowing platform independent of the operating systems on the machines on which it runs. This means that a client program running under UNIX can use an X server running under DOS or some other operating system.

Window Managers

The window manager in X Windows is a special client that provides the set of features that produce the look and feel of the window system. These features include the window layout, the window borders, the way windows are created, how windows are moved, keyboard mappings, color mappings, onscreen menus, and so on. When a client needs to create a new window, the client and the server ask the window manager how this window should be displayed. Since the window manager is just a client, you can replace one window manager with another to change the look and feel of your window system.

Window managers available:

There are more than 20 different window managers for the X Window System. the most commonly used window managers include:

You can customize the menus and actions of your window manager. However, before doing so, you should spend more time using it and you should read the appropriate manual page. You will find directions on customizing the window manager on its manual page.

How do I configure my X Windows Session?
(ie. change default window manager, set up startup applications, ...)

Your actual work session under the X Window System is controlled by a session script. Under xdm(1), the session script is taken form an executable file called .xsession in your home directory. You make a file executable using the command: chmod +x file.

Here is an example of a .xsession file:

#!/bin/sh
PATH=$PATH:/usr/local/X11R5/bin
twm &
xmotd -geometry 500x600+5+5
xclock -digital -geometry 215x50-5+5 &
xbiff -geometry 90x50-230+5 &
xterm -n `hostname` -geometry 80x40+5+375 &
exec xterm -n "Login@`hostname`" -geometry +5+5 -ls

I'll explain this line by line:

  1. makes sure that the session script is executed using /bin/sh.
  2. adds /usr/local/X11R5/bin (x binaries directory) to the path.
  3. starts twm as your window manager.
  4. brings the Message Of The Day client and configures its size and location.
  5. puts a clock at the upper right corner.
  6. puts xbiff (a mail notification client) next to the clock.
  7. starts a secondary x-terminal and sets its size to 80 columns by 40 rows.
  8. starts your primary (login) x-terminal.

Important notes and troubleshooting:

Now how do I change the default settings of my favorite applications?

 

X Resources

The behavior of X Window System clients and the appearance of their windows may be customized using resource variables: when an application starts up, it reads in the current values of all applicable resources, stores them in a private copy of the resource database, and uses them to control its appearance and behavior.

Every application or object in the X Window System has an individual name, which may be individually set for each instance of the object, and a class name, which is usually fixed and the same for all objects in the class. This may sound a litte bit confusing so let's look at a specific example: let's say you have an xterm named login. If you only want to modify the resources of your login xterm, then you'll have to use its individual name, login. In the other hand, if you want to modify the resources of all xterms, then you'll need to use the class name, XTerm. The values of resource variables are usually specified in the form:

objectName*resource: value

Let's say we want to enable the scrollbar:

X Defaults

Now that you learned about resources, you need to learn how to use them to control your applications. Most X-based applications read the .Xdefaults file in your home directory during startup and use the appropriate resource specifications to customize the appearance or characteristics of their windows.
The format for a resource specification in the .Xdefaults file is:

name*resource: value

name: specifies the application name or the name string that restricts the resource assignment to that application or to a component of an application. If this argument is not specified, the resource assignment is globally available to all X applications.

resource: specifies the X resource.
 
value: specifies the value that is to be assigned to the resource.

A sample .Xdefaults file

!
! XTerm resources
!

XTerm*scrollBar: On
XTerm*saveLines: 500
XTerm*background: black
XTerm*foreground: lightskyblue
XTerm*borderColor:   lightslateblue
XTerm*cursorColor:   royalblue
XTerm*pointerColor:  lightslateblue

!
! XClock resources
!

XClock*background: royalblue
XClock*foreground: linen
XClock*analog: False

Notes:

But how do I find out the resources available for customizing an application?

This could be a tough question. Most of the time, you'll find the necessary information in the application's online manual page. If you don't, then you can try using one the following commands and see what you can find:

Please consult the appropriate online manual page to learn about the usage and syntax of the commands listed above.

As a last resort, you can check the /usr/local/X11R5/lib/X11/app-defaults directory and see if you can find a sample resource file associated with the application you are trying to customize.

Can I change the resources of an application that is already running?

If editres(1) can get the widget tree of the application in question then you are in buisness. If not, then you'll have to quit the application, modify the resources then start the application again.

Editres is a great way to customize xterms. It'll let you change the font, colors, title and then some. Again, to learn how to use editres, please read its online manual page.

Can I set resources using command line options?

Sometimes you might want to start up an application with special resources, or maybe want to override some of the default resources. For these reasons, most X Widnows applications communicate with the shell command line and accept various command line arguments. These options are often listed in the application's online man page.

Here is an overview of some quasi-standard command line options:

 

How do I find out which colors are available?

You can use the xcolors application to view the different colors and their colorname. Or you can list the colornames and their RGB values using the showrgb command.

How can I a choose fonts for my applications?

The X Window System offers hundreds of fonts for the display of text in various character sets and styles. You can use the xlsfonts utility to list the fonts available. You can also use xfontsel to display fonts. For more information on these commands, please read their online man pages.

How do I remap the keys on my keyboard?

There are several utilities that help you remap keys on your keyboard. The most popular ones are xmodmap and xkeycaps (basically a graphical front-end to xmodmap). This may sound redundant but to learn more about the usage of these commands, please consult their online man page.

Some useful keyboard binding examples:

You can create a file with a name like .xmodmaprc that includes all your bindings. Then type xmodmap .xmodmaprc to load your mappings. Here is a sample .xmodmaprc file:

          !
          ! make shift-, be < and shift-. be >
          !
          keysym comma = comma less
          keysym period = period greater

          !
          ! swap Caps_Lock and Control_L
          !
          remove Lock = Caps_Lock
          remove Control = Control_L
          keysym Control_L = Caps_Lock
          keysym Caps_Lock = Control_L
          add Lock = Caps_Lock
          add Control = Control_L

How can I change the keyboard or the mouse cursor speed?

Description of common error messages

Can't open display
The XServer is just telling you that you are trying to run an x-application from a vt100 terminal. If you are really logged in from an x-terminal, then you'll have to tell the XServer where you are logged in from. You can use the following command:

If you don't know your displayname, then you can type the who am i command and look for something that looks like name.seas.smu.edu:0.0 in the output.
 

Client is not authorized to connect to Server
This basically means that the client you are trying to run doesn't have access to your display. You can usually overcome this error message by adding the machine you are trying to run the client from to the access list. The syntax for this procedure is:
xhost +hostname.


Copyright © 1996-2009 by Dr. Nikolai Bezroukov. www.softpanorama.org was created as a service to the UN Sustainable Development Networking Programme (SDNP) in the author free time. Submit comments This document is an industrial compilation designed and created exclusively for educational use and is placed under the copyright of the Open Content License(OPL). Site uses AdSense so you need to be aware of Google privacy policy. Original materials copyright belong to respective owners. Quotes are made for educational purposes only in compliance with the fair use doctrine.

Disclaimer:

Last modified: August 10, 2009