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

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:

    setenv DISPLAY displayname:0.0

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.

Top Visited
Switchboard
Latest
Past week
Past month

NEWS CONTENTS

Old News ;-)

[Nov 09, 2017] TERM strings by Tom Ryder

Jan 26, 2013 | sanctum.geek.nz

A certain piece of very misleading advice is often given online to users having problems with the way certain command-line applications are displaying in their terminals. This is to suggest that the user change the value of their TERM environment variable from within the shell, doing something like this:

$ TERM=xterm-256color

This misinformation sometimes extends to suggesting that users put the forced TERM change into their shell startup scripts. The reason this is such a bad idea is that it forces your shell to assume what your terminal is, and thereby disregards the initial terminal identity string sent by the emulator. This leads to a lot of confusion when one day you need to connect with a very different terminal emulator.

Accounting for differences

All terminal emulators are not created equal. Certainly, not all of them are xterm(1) , although many other terminal emulators do a decent but not comprehensive job of copying it. The value of the TERM environment variable is used by the system running the shell to determine what the terminal connecting to it can and cannot do, what control codes to send to the program to use those features, and how the shell should understand the input of certain key codes, such as the Home and End keys. These things in particular are common causes of frustration for new users who turn out to be using a forced TERM string.

Instead, focus on these two guidelines for setting TERM :

  1. Avoid setting TERM from within the shell, especially in your startup scripts like .bashrc or .bash_profile . If that ever seems like the answer, then you are probably asking the wrong question! The terminal identification string should always be sent by the terminal emulator you are using; if you do need to change it, then change it in the settings for the emulator.
  2. Always use an appropriate TERM string that accurately describes what your choice of terminal emulator can and cannot display. Don't make an rxvt(1) terminal identify itself as xterm ; don't make a linux console identify itself as vt100 ; and don't make an xterm(1) compiled without 256 color support refer to itself as xterm-256color .

In particular, note that sometimes for compatibility reasons, the default terminal identification used by an emulator is given as something generic like xterm , when in fact a more accurate or comprehensive terminal identity file is more than likely available for your particular choice of terminal emulator with a little searching.

An example that surprises a lot of people is the availability of the putty terminal identity file, when the application defaults to presenting itself as an imperfect xterm(1) emulator.

Configuring your emulator's string

Before you change your terminal string in its settings, check whether the default it uses is already the correct one, with one of these:

$ echo $TERM
$ tset -q

Most builds of rxvt(1) , for example, should already use the correct TERM string by default, such as rxvt-unicode-256color for builds with 256 colors and Unicode support.

Where to configure which TERM string your terminal uses will vary depending on the application. For xterm(1) , your .Xresources file should contain a definition like the below:

XTerm*termName: xterm-256color

For rxvt(1) , the syntax is similar:

URxvt*termName: rxvt-unicode-256color

Other GTK and Qt emulators sometimes include the setting somewhere in their preferences. Look for mentions of xterm , a common fallback default.

For Windows PuTTY, it's configurable under the "'Connections > Data"' section:

Setting the terminal string in PuTTY

More detail about configuring PuTTY for connecting to modern systems can be found in my article on configuring PuTTY .

Testing your TERM string

On GNU/Linux systems, an easy way to test the terminal capabilities (particularly effects like colors and reverse video) is using the msgcat(1) utility:

$ msgcat --color=test

This will output a large number of tests of various features to the terminal, so that you can check their appearance is what you expect.

Finding appropriate terminfo(5) definitions

On GNU/Linux systems, the capabilities and behavior of various terminal types is described using terminfo(5) files, usually installed as part of the ncurses package. These files are often installed in /lib/terminfo or /usr/share/terminfo , in subdirectories by first letter.

In order to use a particular TERM string, an appropriate file must exist in one of these directories. On Debian-derived systems, a large collection of terminal types can be installed to the system with the ncurses-term package.

For example, the following variants of the rxvt terminal emulator are all available:

$ cd /usr/share/terminfo/r
$ ls rxvt*
rxvt-16color  rxvt-256color  rxvt-88color  rxvt-color  rxvt-cygwin
rxvt-cygwin-native  rxvt+pcfkeys  rxvt-unicode-256color  rxvt-xpm
Private and custom terminfo(5) files

If you connect to a system that doesn't have a terminfo(5) definition to match the TERM definition for your particular terminal, you might get a message similar to this on login:

setterm: rxvt-unicode-256color: unknown terminal type
tput: unknown terminal "rxvt-unicode-256color"
$

If you're not able to install the appropriate terminal definition system-wide, one technique is to use a private .terminfo directory in your home directory containing the definitions you need:

$ cd ~/.terminfo
$ find
.
./x
./x/xterm-256color
./x/xterm
./r
./r/rxvt-256color
./r/rxvt-unicode-256color
./r/rxvt
./s
./s/screen
./s/screen-256color
./p
./p/putty-256color
./p/putty

You can copy this to your home directory on the servers you manage with a tool like scp :

$ scp -r .terminfo server:
TERM and multiplexers

Terminal multiplexers like screen(1) and tmux(1) are special cases, and they cause perhaps the most confusion to people when inaccurate TERM strings are used. The tmux FAQ even opens by saying that most of the display problems reported by people are due to incorrect TERM settings, and a good portion of the codebase in both multiplexers is dedicated to negotiating the differences between terminal capacities.

This is because they are "terminals within terminals", and provide their own functionality only within the bounds of what the outer terminal can do. In addition to this, they have their own type for terminals within them; both of them use screen and its variants, such as screen-256color .

It's therefore very important to check that both the outer and inner definitions for TERM are correct. In .screenrc it usually suffices to use a line like the following:

term screen

Or in .tmux.conf :

set-option -g default-terminal screen

If the outer terminals you use consistently have 256 color capabilities, you may choose to use the screen-256color variant instead.

If you follow all of these guidelines, your terminal experience will be much smoother, as your terminal and your system will understand each other that much better. You may find that this fixes a lot of struggles with interactive tools like vim(1) , for one thing, because if the application is able to divine things like the available color space directly from terminal information files, it saves you from having to include nasty hacks on the t_Co variable in your .vimrc . Posted in Terminal Tagged term strings , terminal types , terminfo

[Dec 17, 2009] Top Ten Things I Miss in Windows

Thoughts on Technology

Klipper/Copy & Paste Manager

I use this one alot when I am either coding or writing a research paper for school. More often than not I find I have copied something new only to discover I need to paste a link or block of code again from two copies back. Having a tray icon where I can recall the last ten copies or so is mighty useful.

Gnome-Do

Most anyone who uses the computer in their everyday work will tell you that less mouse clicks means faster speed and thus (typically) more productivity. Gnome-Do is a program that allows you to cut down on mouse clicks (so long as you know what program you are looking to load). The jist of what it does is this: you assign a series of hot keys to call up the search bar (personally I use control+alt+space) and then you start typing in the name of an application or folder you want to open and it will start searching for it - once the correct thing is displayed all you need to do is tap enter to load it up. The best part is that it remembers which programs you use most often. Meaning that most times you only need to type the first letter or two of a commonly used application for it to find the one you are looking for.

[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.

Recommended Links

Google matched content

Softpanorama Recommended

Top articles

Sites



Etc

Society

Groupthink : Two Party System as Polyarchy : Corruption of Regulators : Bureaucracies : Understanding Micromanagers and Control Freaks : Toxic Managers :   Harvard Mafia : Diplomatic Communication : Surviving a Bad Performance Review : Insufficient Retirement Funds as Immanent Problem of Neoliberal Regime : PseudoScience : Who Rules America : Neoliberalism  : The Iron Law of Oligarchy : Libertarian Philosophy

Quotes

War and Peace : Skeptical Finance : John Kenneth Galbraith :Talleyrand : Oscar Wilde : Otto Von Bismarck : Keynes : George Carlin : Skeptics : Propaganda  : SE quotes : Language Design and Programming Quotes : Random IT-related quotesSomerset Maugham : Marcus Aurelius : Kurt Vonnegut : Eric Hoffer : Winston Churchill : Napoleon Bonaparte : Ambrose BierceBernard Shaw : Mark Twain Quotes

Bulletin:

Vol 25, No.12 (December, 2013) Rational Fools vs. Efficient Crooks The efficient markets hypothesis : Political Skeptic Bulletin, 2013 : Unemployment Bulletin, 2010 :  Vol 23, No.10 (October, 2011) An observation about corporate security departments : Slightly Skeptical Euromaydan Chronicles, June 2014 : Greenspan legacy bulletin, 2008 : Vol 25, No.10 (October, 2013) Cryptolocker Trojan (Win32/Crilock.A) : Vol 25, No.08 (August, 2013) Cloud providers as intelligence collection hubs : Financial Humor Bulletin, 2010 : Inequality Bulletin, 2009 : Financial Humor Bulletin, 2008 : Copyleft Problems Bulletin, 2004 : Financial Humor Bulletin, 2011 : Energy Bulletin, 2010 : Malware Protection Bulletin, 2010 : Vol 26, No.1 (January, 2013) Object-Oriented Cult : Political Skeptic Bulletin, 2011 : Vol 23, No.11 (November, 2011) Softpanorama classification of sysadmin horror stories : Vol 25, No.05 (May, 2013) Corporate bullshit as a communication method  : Vol 25, No.06 (June, 2013) A Note on the Relationship of Brooks Law and Conway Law

History:

Fifty glorious years (1950-2000): the triumph of the US computer engineering : Donald Knuth : TAoCP and its Influence of Computer Science : Richard Stallman : Linus Torvalds  : Larry Wall  : John K. Ousterhout : CTSS : Multix OS Unix History : Unix shell history : VI editor : History of pipes concept : Solaris : MS DOSProgramming Languages History : PL/1 : Simula 67 : C : History of GCC developmentScripting Languages : Perl history   : OS History : Mail : DNS : SSH : CPU Instruction Sets : SPARC systems 1987-2006 : Norton Commander : Norton Utilities : Norton Ghost : Frontpage history : Malware Defense History : GNU Screen : OSS early history

Classic books:

The Peter Principle : Parkinson Law : 1984 : The Mythical Man-MonthHow to Solve It by George Polya : The Art of Computer Programming : The Elements of Programming Style : The Unix Haterís Handbook : The Jargon file : The True Believer : Programming Pearls : The Good Soldier Svejk : The Power Elite

Most popular humor pages:

Manifest of the Softpanorama IT Slacker Society : Ten Commandments of the IT Slackers Society : Computer Humor Collection : BSD Logo Story : The Cuckoo's Egg : IT Slang : C++ Humor : ARE YOU A BBS ADDICT? : The Perl Purity Test : Object oriented programmers of all nations : Financial Humor : Financial Humor Bulletin, 2008 : Financial Humor Bulletin, 2010 : The Most Comprehensive Collection of Editor-related Humor : Programming Language Humor : Goldman Sachs related humor : Greenspan humor : C Humor : Scripting Humor : Real Programmers Humor : Web Humor : GPL-related Humor : OFM Humor : Politically Incorrect Humor : IDS Humor : "Linux Sucks" Humor : Russian Musical Humor : Best Russian Programmer Humor : Microsoft plans to buy Catholic Church : Richard Stallman Related Humor : Admin Humor : Perl-related Humor : Linus Torvalds Related humor : PseudoScience Related Humor : Networking Humor : Shell Humor : Financial Humor Bulletin, 2011 : Financial Humor Bulletin, 2012 : Financial Humor Bulletin, 2013 : Java Humor : Software Engineering Humor : Sun Solaris Related Humor : Education Humor : IBM Humor : Assembler-related Humor : VIM Humor : Computer Viruses Humor : Bright tomorrow is rescheduled to a day after tomorrow : Classic Computer Humor

The Last but not Least Technology is dominated by two types of people: those who understand what they do not manage and those who manage what they do not understand ~Archibald Putt. Ph.D


Copyright © 1996-2018 by Dr. Nikolai Bezroukov. www.softpanorama.org was initially created as a service to the (now defunct) UN Sustainable Development Networking Programme (SDNP) in the author free time and without any remuneration. This document is an industrial compilation designed and created exclusively for educational use and is distributed under the Softpanorama Content License. Original materials copyright belong to respective owners. Quotes are made for educational purposes only in compliance with the fair use doctrine.

FAIR USE NOTICE This site contains copyrighted material the use of which has not always been specifically authorized by the copyright owner. We are making such material available to advance understanding of computer science, IT technology, economic, scientific, and social issues. We believe this constitutes a 'fair use' of any such copyrighted material as provided by section 107 of the US Copyright Law according to which such material can be distributed without profit exclusively for research and educational purposes.

This is a Spartan WHYFF (We Help You For Free) site written by people for whom English is not a native language. Grammar and spelling errors should be expected. The site contain some broken links as it develops like a living tree...

You can use PayPal to make a contribution, supporting development of this site and speed up access. In case softpanorama.org is down you can use the at softpanorama.info

Disclaimer:

The statements, views and opinions presented on this web page are those of the author (or referenced source) and are not endorsed by, nor do they necessarily reflect, the opinions of the author present and former employers, SDNP or any other organization the author may be associated with. We do not warrant the correctness of the information provided or its fitness for any purpose.

The site uses AdSense so you need to be aware of Google privacy policy. You you do not want to be tracked by Google please disable Javascript for this site. This site is perfectly usable without Javascript.

Last modified: December, 26, 2017