X(7)

๐Ÿ’– NAME ๐Ÿ’–

Okay bestie, welcome to X(7) โ€” the manual page for X, aka a portable, network-transparent window system. That's the whole vibe.


โœจ OVERVIEW โœจ

The X Window System is a network transparent window system that runs on a wide range of computing and graphics machines. Building the X.Org Foundation software distribution should be relatively straightforward on most ANSI C and POSIX compliant systems. Commercial implementations are also available for a wide range of platforms. ๐Ÿ’…

The X.Org Foundation requests that the following names be used when referring to this software:

  • X
  • X Window System
  • X Version 11
  • X Window System, Version 11
  • X11

X Window System is a trademark of The Open Group. ๐Ÿ‘‘

๐ŸŒธ DESCRIPTION ๐ŸŒธ

X Window System servers run on computers with bitmap displays. The server distributes user input to and accepts output requests from various client programs through a variety of different interprocess communication channels. The most common case is client programs running on the same machine as the server, but clients can also be run transparently from other machines โ€” including machines with different architectures and operating systems. network transparency slay โœจ

X supports overlapping hierarchical subwindows and text and graphics operations, on both monochrome and color displays. For a full explanation of the functions that are available, see the Xlib - C Language X Interface manual, the X Window System Protocol specification, the X Toolkit Intrinsics - C Language Interface manual, and various toolkit documents. Those manuals, specifications, & documents may be found in /usr/share/doc or on the X.Org Foundation website at https://www.x.org/releases/current/doc/. ๐Ÿฆ‹

The number of programs that use X is quite large. Sample programs provided by the X.Org Foundation include:

  • a terminal emulator: xterm
  • a window manager: twm
  • a compositing manager: xcompmgr
  • a display manager: xdm
  • a console redirect program: xconsole
  • utilities for managing input and output devices: xinput and xrandr
  • resource listing/manipulation tools: appres, editres
  • access control programs: xauth, xhost, and iceauth
  • user preference setting programs: transset, xrdb, xcmsdb, xset, xsetroot, xstdcmap, and xmodmap
  • clocks: xclock and oclock
  • font display utilities: xfd and xfontsel
  • utilities for listing information about displays, extensions, and resources: xdpyinfo, xdriinfo, xvinfo, xwininfo, xlsclients, xprop, xlsatoms, xlsclients, and xlsfonts
  • screen image manipulation utilities: xwd, xwud, and xmag
  • a performance measurement utility: x11perf
  • a font compiler: bdftopcf
  • a font server and related utilities: xfs, xfsinfo, fslsfonts, fstobdf
  • a display server and related utilities: Xserver, rgb, mkfontdir
  • a clipboard manager: xclipboard
  • keyboard description compiler and related utilities: xkbcomp, setxkbmap xkbprint, xkbbell, xkbevd, xkbvleds, and xkbwatch
  • a utility to terminate clients: xkill
  • a utility to cause part or all of the screen to be redrawn: xrefresh

Many other utilities, window managers, games, toolkits, etc. are included as packages in many operating system distributions, or are available on the Internet. See your site administrator or distro package manager for details. ๐Ÿซถ

๐ŸŽ€ STARTING UP ๐ŸŽ€

There are two main ways of getting the X server and an initial set of client applications started. The particular method used depends on what operating system you are running and whether or not you use other window systems in addition to X. ๐Ÿ’–

๐Ÿ’ป Display Manager ๐Ÿ’ป

If you want to always have X running on your display, your site administrator can set your machine up to use a Display Manager such as xdm, gdm, or kdm. This program is typically started by the system at boot time and takes care of keeping the server running and getting users logged in.

If you are running one of these display managers, you will normally see a window on the screen welcoming you to the system and asking for your login information. Simply type them in as you would at a normal terminal. If you make a mistake, the display manager will display an error message and ask you to try again. After you have successfully logged in, the display manager will start up your X environment. The documentation for the display manager you use can provide more details. ๐ŸŒŸ

๐Ÿ› ๏ธ xinit (run manually from the shell) ๐Ÿ› ๏ธ

Sites that support more than one window system might choose to use the xinit program for starting X manually. If this is true for your machine, your site administrator will probably have provided a program named "x11", "startx", or "xstart" that will do site-specific initialization (such as loading convenient default resources, running a window manager, displaying a clock, and starting several terminal emulators) in a nice way. If not, you can build such a script using the xinit program.

This utility simply runs one user-specified program to start the server, runs another to start up any desired clients, and then waits for either to finish. Since either or both of the user-specified programs may be a shell script, this gives substantial flexibility at the expense of a nice interface.

๐Ÿšจ For this reason, xinit is not intended for end users. bestie, do not make it your whole personality unless you know what you're doing ๐Ÿ’€

๐ŸŒˆ DISPLAY NAMES ๐ŸŒˆ

From the user's perspective, every X server has a display name of the form:

hostname:displaynumber.screennumber

or

protocol/hostname:displaynumber.screennumber

This information is used by the application to determine how it should connect to the server and which screen it should use by default (on displays with multiple monitors): โœจ

๐Ÿงš protocol ๐Ÿงš

The protocol specifies the protocol to use for communication. Exactly which protocols are supported is platform dependent, but the most commonly supported ones are:

  • tcp โ€” TCP over IPv4 or IPv6
  • inet โ€” TCP over IPv4 only
  • inet6 โ€” TCP over IPv6 only
  • unix โ€” UNIX Domain Sockets (same host only)
  • local โ€” Platform preferred local connection method

If the protocol is not specified, Xlib uses whatever it believes is the most efficient transport. ๐Ÿ’…

๐Ÿ  hostname ๐Ÿ 

The hostname specifies the name of the machine to which the display is physically connected. If the hostname is not given, a connection to a server on the same machine will be used. ๐Ÿซถ

๐Ÿ”ข displaynumber ๐Ÿ”ข

The phrase "display" is usually used to refer to a collection of monitors that share a common set of input devices (keyboard, mouse, tablet, etc.). Most workstations tend to only have one display. Larger, multi-user systems, however, frequently have several displays so that more than one person can be doing graphics work at once.

To avoid confusion, each display on a machine is assigned a display number (beginning at 0) when the X server for that display is started. The display number must always be given in a display name. No cap. ๐Ÿ‘‘

๐Ÿ–ฅ๏ธ screennumber ๐Ÿ–ฅ๏ธ

Some displays share their input devices among two or more monitors. These may be configured as a single logical screen, which allows windows to move across screens, or as individual screens, each with their own set of windows.

If configured such that each monitor has its own set of windows, each screen is assigned a screen number (beginning at 0) when the X server for that display is started. If the screen number is not given, screen 0 will be used. ๐ŸŒŸ

On POSIX systems, the default display name is stored in your DISPLAY environment variable. This variable is set automatically by the xterm terminal emulator. However, when you log into another machine on a network, you may need to set DISPLAY by hand to point to your display. For example,

% setenv DISPLAY myws:0
$ DISPLAY=myws:0; export DISPLAY

The ssh program can be used to start an X program on a remote machine; it automatically sets the DISPLAY variable correctly. ๐Ÿฆ‹

Finally, most X programs accept a command line option of -display displayname to temporarily override the contents of DISPLAY. This is most commonly used to pop windows on another person's screen or as part of a "remote shell" command to start an xterm pointing back to your display. For example,

% xeyes -display joesws:0 -geometry 1000x1000+0+0
% rsh big xterm -display myws:0 -ls </dev/null &

X servers listen for connections on a variety of different communications channels (network byte streams, shared memory, etc.). Since there can be more than one way of contacting a given server, the hostname part of the display name is used to determine the type of channel (also called a transport layer) to be used. X servers generally support the following types of connections:

๐Ÿ’œ local ๐Ÿ’œ

The hostname part of the display name should be the empty string. For example: :0, :1, and :0.1. The most efficient local transport will be chosen.

๐Ÿ”ฅ TCP/IP ๐Ÿ”ฅ

The hostname part of the display name should be the server machine's hostname or IP address. Full Internet names, abbreviated names, IPv4 addresses, and IPv6 addresses are all allowed. For example: x.org:0, expo:0, [::1]:0, 198.112.45.11:0, bigmachine:1, and hydra:0.1.

๐Ÿ’… LOCAL CONNECTIONS ๐Ÿ’…

Okay so bestie, listen โ€” on operating systems that support local connections other than Unix Domain sockets (we're talking SVR3 and SVR4 here), there's a compiled-in list that says the order in which local connections should be attempted. And yeah, that list can be overridden by the XLOCAL environment variable (more on that below, don't worry ๐Ÿซถ). If the display name indicates a best-choice connection should be made (think :0.0), each connection mechanism gets tried in turn until a connection actually succeeds or there are literally no more mechanisms left. No cap.

The XLOCAL environment variable should contain a list of one or more of the following:

NAMED
PTS
SCO
UNIX

which represent SVR4 Named Streams pipe, Old-style USL Streams pipe, SCO XSight Streams pipe, and Unix domain sockets, respectively โœจ. You can pick a single mechanism (like XLOCAL=NAMED), or give it an ordered list (like XLOCAL="NAMED:PTS:SCO"). This variable overrides the compiled-in defaults. For SVR4 it is recommended that NAMED be the first preference connection. The default setting is platform-dependent โ€” iykyk, it depends on your platform.

To globally override the compiled-in defaults, you should define (and export if you're using sh or ksh) XLOCAL globally. If you use startx(1) or xinit(1), the definition should be at the top of your .xinitrc file. If you use xdm(1), the definitions should be early on in the /usr/lib/X11/xdm/Xsession script. Slay, get those definitions in early ๐Ÿ’….


๐Ÿ” ACCESS CONTROL ๐Ÿ”

An X server can use several types of access control. The mechanisms provided in Release 7 are:

  • Host Access โ€” Simple host-based access control. Very demure, very mindful.
  • MIT-MAGIC-COOKIE-1 โ€” Shared plain-text "cookies".
  • XDM-AUTHORIZATION-1 โ€” Secure DES based private-keys.
  • SUN-DES-1 โ€” Based on Sun's secure rpc system.
  • Server Interpreted โ€” Server-dependent methods of access control.

Xdm initializes access control for the server and also places authorization information in a file accessible to the user ๐ŸŽ€.

Normally, the list of hosts from which connections are always accepted should be empty, so that only clients which are explicitly authorized can connect to the display. When you add entries to the host list (with xhost), the server no longer performs any authorization on connections from those machines. Be careful with this. Like, genuinely โ€” that's a whole security vibe shift, bestie.

The file from which Xlib extracts authorization data can be specified with the environment variable XAUTHORITY, and defaults to the file .Xauthority in the home directory. Xdm uses $HOME/.Xauthority and will create it or merge in authorization records if it already exists when a user logs in ๐ŸŒธ.

If you use several machines and share a common home directory across all of the machines by means of a network file system, you never really have to worry about authorization files โ€” the system should work correctly by default. Iconic behavior, honestly. Otherwise, as the authorization files are machine-independent, you can simply copy the files to share them. To manage authorization files, use xauth. This program allows you to extract records and insert them into other files. Using this, you can send authorization to remote machines when you login, if the remote machine does not share a common home directory with your local machine. ๐Ÿฆ‹

Note that authorization information transmitted in the clear'' through a network file system or using `ftp` or `rcp` can be stolen'' by a network eavesdropper, and as such may enable unauthorized access. In many environments, this level of security is not a concern, but if it is, you need to know the exact semantics of the particular authorization data to know if this is actually a problem. Don't be out here leaking your auth info, bestie ๐Ÿ˜ญ

For more information on access control, see the Xsecurity(7) manual page.


๐Ÿ“ GEOMETRY SPECIFICATIONS ๐Ÿ“

One of the advantages of using window systems instead of hardwired terminals is that applications don't have to be restricted to a particular size or location on the screen. Like, freedom?? We love to see it ๐Ÿ’–. Although the layout of windows on a display is controlled by the window manager that the user is running (described below), most X programs accept a command line argument of the form -geometry WIDTHxHEIGHT+XOFF+YOFF (where WIDTH, HEIGHT, XOFF, and YOFF are numbers) for specifying a preferred size and location for this application's main window.

The WIDTH and HEIGHT parts of the geometry specification are usually measured in either pixels or characters, depending on the application. The XOFF and YOFF parts are measured in pixels and are used to specify the distance of the window from the left or right and top and bottom edges of the screen, respectively. Both types of offsets are measured from the indicated edge of the screen to the corresponding edge of the window โœจ.

The X offset may be specified in the following ways:

  • +XOFF โ€” The left edge of the window is to be placed XOFF pixels in from the left edge of the screen (i.e., the X coordinate of the window's origin will be XOFF). XOFF may be negative, in which case the window's left edge will be off the screen. Shipper of chaos, but okay ๐Ÿ’€
  • -XOFF โ€” The right edge of the window is to be placed XOFF pixels in from the right edge of the screen. XOFF may be negative, in which case the window's right edge will be off the screen.

The Y offset has similar meanings:

  • +YOFF โ€” The top edge of the window is to be YOFF pixels below the top edge of the screen (i.e., the Y coordinate of the window's origin will be YOFF). YOFF may be negative, in which case the window's top edge will be off the screen.
  • -YOFF โ€” The bottom edge of the window is to be YOFF pixels above the bottom edge of the screen. YOFF may be negative, in which case the window's bottom edge will be off the screen.

Offsets must be given as pairs; in other words, in order to specify either XOFF or YOFF both must be present. No lone-wolf offsets, they're a package deal ๐Ÿซถ. Windows can be placed in the four corners of the screen using the following specifications:

  • +0+0 โ€” upper left hand corner.
  • -0+0 โ€” upper right hand corner.
  • -0-0 โ€” lower right hand corner.
  • +0-0 โ€” lower left hand corner.

In the following examples, a terminal emulator is placed in roughly the center of the screen and a load average monitor, mailbox, and clock are placed in the upper right hand corner:

xterm -fn 6x10 -geometry 80x24+30+200 &
xclock -geometry 48x48-0+0 &
xload -geometry 48x48-96+0 &
xbiff -geometry 48x48-48+0 &

Look at that layout. Chef's kiss ๐Ÿ‘‘.


๐ŸชŸ WINDOW MANAGERS ๐ŸชŸ

The layout of windows on the screen is controlled by special programs called window managers. Although many window managers will honor geometry specifications as given, others may choose to ignore them (requiring the user to explicitly draw the window's region on the screen with the pointer, for example). Rude, but okay ๐Ÿ™ˆ.

Since window managers are regular (albeit complex) client programs, a variety of different user interfaces can be built. The X.Org Foundation provides a window manager named twm which supports overlapping windows, popup menus, point-and-click or click-to-type input models, title bars, nice icons (and an icon manager for those who don't like separate icon windows). twm really said "I contain multitudes" ๐Ÿ’….

See your distro package manager for other popular window managers.


๐Ÿ”ค FONT NAMES ๐Ÿ”ค

Collections of characters for displaying text and symbols in X are known as fonts. A font typically contains images that share a common appearance and look nice together (for example, a single size, boldness, slant, and character set). Similarly, collections of fonts that are based on a common type face (the variations are usually called roman, bold, italic, bold italic, oblique, and bold oblique) are called families. Found family, but make it typography ๐Ÿฅบ.

Fonts come in various sizes. The X server supports scalable fonts, meaning it is possible to create a font of arbitrary size from a single source for the font. The server supports scaling from outline fonts and bitmap fonts. Scaling from outline fonts usually produces significantly better results than scaling from bitmap fonts. Ngl, outlines just hit different โœจ.

An X server can obtain fonts from individual files stored in directories in the file system, or from one or more font servers, or from a mixture of directories and font servers. The list of places the server looks when trying to find a font is controlled by its font path. Although most installations will choose to have the server start up with all of the commonly used font directories in the font path, the font path can be changed at any time with the xset program. However, it is important to remember that the directory names are on the server's machine, not on the application's โ€” like, do not get it twisted, bestie ๐Ÿ˜ญ.

Bitmap font files are usually created by compiling a textual font description into binary form, using bdftopcf. Font databases are created by running the mkfontdir program in the directory containing the source or compiled versions of the fonts. Whenever fonts are added to a directory, mkfontdir should be rerun so that the server can find the new fonts. To make the server reread the font database, reset the font path with the xset program. For example, to add a font to a private directory, the following commands could be used:

% cp newfont.pcf ~/myfonts
% mkfontdir ~/myfonts
% xset fp rehash

The xfontsel and xlsfonts programs can be used to browse through the fonts available on a server. Font names tend to be fairly long as they contain all of the information needed to uniquely identify individual fonts. However, the X server supports wildcarding of font names, so the full specification

-adobe-courier-medium-r-normal--10-100-75-75-m-60-iso8859-1

might be abbreviated as:

-*-courier-medium-r-normal--*-100-*-*-*-*-iso8859-1

Because the shell also has special meanings for * and ?, wildcarded font names should be quoted:

% xlsfonts -fn '-*-courier-medium-r-normal--*-100-*-*-*-*-*-*'

The xlsfonts program can be used to list all of the fonts that match a given pattern. With no arguments, it lists all available fonts. This will usually list the same font at many different sizes. To see just the base scalable font names, try using one of the following patterns:

-*-*-*-*-*-*-0-0-0-0-*-0-*-*
-*-*-*-*-*-*-0-0-75-75-*-0-*-*
-*-*-*-*-*-*-0-0-100-100-*-0-*-*

To convert one of the resulting names into a font at a specific size, replace one of the first two zeros with a nonzero value. The field containing the first zero is for the pixel size; replace it with a specific height in pixels to name a font at that size. Alternatively, the field containing the second zero is for the point size; replace it with a specific size in decipoints (there are 722.7 decipoints to the inch) to name a font at that size. The last zero is an average width field, measured in tenths of pixels; some servers will anamorphically scale if this value is specified. Anamorphically ๐Ÿ˜ณ โ€” yeah, they said it, iconic vocabulary fr.


โœจ FONT SERVER NAMES โœจ

okay so sometimes fonts don't live on your machine at all โ€” they live on a whole other machine, a font server, and it's out there accepting TCP connections like the main character it is ๐Ÿ’… you can name one of those with any of these forms:

tcp/hostname:port
tcp/hostname:port/cataloguelist
  • the hostname is literally the name (or the decimal numeric address, no cap) of the machine the font server is running on ๐Ÿ–ฅ๏ธ
  • the port is the decimal TCP port that font server is listening on for connections โ€” decimal, bestie, write it in decimal ๐Ÿ”ข
  • the cataloguelist is a list of catalogue names, and you separate them with + (that's the separator, that's the vibe) โž•

Examples, because examples ate: tcp/x.org:7100, tcp/198.112.45.11:7100/all โญ


๐ŸŽจ COLOR NAMES ๐ŸŽจ

Most applications give you ways to tailor the colors of stuff in the text and graphics they display โ€” usually through resources or command line arguments, iykyk. And a color can be specified either by an abstract color name or by a numerical color specification ๐Ÿ”ฅ

The numerical spec can identify a color in either device-dependent (RGB) terms or device-independent terms. Also: color strings are case-insensitive. periodt ๐Ÿ’…

Abstract names, the easy route ๐ŸŒธ

X supports abstract color names, like "red", "blue" โ€” the classics. You get a value for that abstract name by searching one or more color name databases. Xlib searches zero or more client-side databases first; the number, location, and content of those databases is implementation dependent (so like, don't come for me, it depends ๐Ÿ™ˆ). If the name isn't found there, the color gets looked up in the X server's database. The text form of that server database is commonly stored in /usr/share/X11/rgb.txt ๐Ÿ“

Numerical specs, the nerdy route ๐Ÿ”ฌ

A numerical color specification is a color space name plus a set of values, in this syntax:

<color_space_name>:<value>/.../<value>

RGB Device specs

An RGB Device specification is identified by the prefix rgb: and looks like this:

rgb:<red>/<green>/<blue>

    <red>, <green>, <blue> := h | hh | hhh | hhhh
    h := single hexadecimal digits

So h = value scaled in 4 bits, hh = scaled in 8 bits, hhh = scaled in 12 bits, and hhhh = scaled in 16 bits, respectively. These values get passed directly to the X server, and they're assumed to be gamma corrected โœ…

The eight primary colors can be represented as:

  • black โ€” rgb:0/0/0
  • red โ€” rgb:ffff/0/0
  • green โ€” rgb:0/ffff/0
  • blue โ€” rgb:0/0/ffff
  • yellow โ€” rgb:ffff/ffff/0
  • magenta โ€” rgb:ffff/0/ffff
  • cyan โ€” rgb:0/ffff/ffff
  • white โ€” rgb:ffff/ffff/ffff

the old-school # syntax (still works, butโ€ฆ)

For backward compatibility, an older syntax for RGB Device is supported โ€” but its continued use is not encouraged, bestie, it's giving deprecated energy ๐Ÿ’€ The syntax is an initial sharp sign character followed by a numeric specification, in one of these formats:

#RGB            (4 bits each)
#RRGGBB         (8 bits each)
#RRRGGGBBB      (12 bits each)
#RRRRGGGGBBBB   (16 bits each)

The R, G, and B each represent single hexadecimal digits. When fewer than 16 bits each are specified, they represent the most-significant bits of the value โ€” which is unlike the rgb: syntax, where values are scaled. For example, #3a7 is the same as #3000a0007000. write that down ๐Ÿ“

RGB intensity specs

An RGB intensity specification is identified by the prefix rgbi: and has this syntax:

rgbi:<red>/<green>/<blue>

The red, green, and blue are floating point values between 0.0 and 1.0, inclusive. They represent linear intensity values โ€” 1.0 means full intensity, 0.5 means half intensity, and so on. These values will be gamma corrected by Xlib before being sent to the X server ๐ŸŒˆ

The input format for these values is an optional sign, a string of numbers possibly containing a decimal point, and an optional exponent field containing an E or e followed by a possibly signed integer string. fancy ๐Ÿ”ฅ

device-independent specs

The standard device-independent string specifications have this syntax:

CIEXYZ:<X>/<Y>/<Z>   (none, 1, none)
CIEuvY:<u>/<v>/<Y>   (~.6, ~.6, 1)
CIExyY:<x>/<y>/<Y>   (~.75, ~.85, 1)
CIELab:<L>/<a>/<b>   (100, none, none)
CIELuv:<L>/<u>/<v>   (100, none, none)
TekHVC:<H>/<V>/<C>   (360, 100, 100)

All of the values (C, H, V, X, Y, Z, a, b, u, v, y, x) are floating point values. Some of them are constrained to be between zero and some upper bound โ€” and those upper bounds are the ones chillin' in the parentheses up there ๐Ÿ‘†

The syntax for these values is an optional + or - sign, a string of digits possibly containing a decimal point, and an optional exponent field consisting of an E or e followed by an optional + or - followed by a string of digits. same energy as before, slay ๐Ÿ’œ

For more information on device independent color, see the Xlib reference manual. (go read it, it's right there ๐Ÿซถ)

โŒจ๏ธ KEYBOARDS โŒจ๏ธ

okay this part is so iconic because the X keyboard model is broken into two layers and once you get it you get it ๐Ÿงš

  • server-specific codes โ€” called keycodes โ€” which represent the physical keys ๐ŸŽน
  • server-independent symbols โ€” called keysyms โ€” which represent the letters or words that appear on the keys ๐Ÿ”ค

Two tables are kept in the server for converting keycodes to keysyms. Two. Tables. Let's meet them ๐Ÿ’–

modifier list

Some keys (think Shift, Control, and Caps Lock) are known as modifier keys, and they're used to select different symbols attached to a single key โ€” like how Shift-a generates a capital A, and Control-l generates a control character ^L โœจ

The server keeps a list of keycodes corresponding to the various modifier keys. Whenever a key is pressed or released, the server generates an event that contains the keycode of the indicated key as well as a mask specifying which of the modifier keys are currently pressed. Most servers set up this list to initially contain the various shift, control, and shift lock keys on the keyboard ๐Ÿซถ

keymap table

Applications translate event keycodes and modifier masks into keysyms using a keysym table, which contains one row for each keycode and one column for various modifier states ๐Ÿ“Š

This table is initialized by the server to correspond to normal typewriter conventions. The exact semantics of how the table gets interpreted to produce keysyms depends on the particular program, libraries, and language input method used โ€” but the following conventions for the first four keysyms in each row are generally adhered to ๐Ÿ‘‡

The first four elements of the list are split into two groups of keysyms:

  • Group 1 contains the first and second keysyms
  • Group 2 contains the third and fourth keysyms

Within each group, if the first element is alphabetic and the second element is the special keysym NoSymbol, then the group is treated as equivalent to a group in which the first element is the lowercase letter and the second element is the uppercase letter ๐Ÿ” 

Switching between groups is controlled by the keysym named MODE SWITCH โ€” you do it by attaching that keysym to some key and attaching that key to any one of the modifiers Mod1 through Mod5. This modifier is called the ``group modifier.'' Group 1 is used when the group modifier is off, and Group 2 is used when the group modifier is on ๐Ÿ”€

Within a group, the modifier state determines which keysym to use:

  • The first keysym is used when the Shift and Lock modifiers are off.
  • The second keysym is used when the Shift modifier is on, when the Lock modifier is on and the second keysym is uppercase alphabetic, or when the Lock modifier is on and is interpreted as ShiftLock.
  • Otherwise, when the Lock modifier is on and is interpreted as CapsLock, the state of the Shift modifier is applied first to select a keysym; but if that keysym is lowercase alphabetic, then the corresponding uppercase keysym is used instead. ๐Ÿ˜ญ (yes it's a whole chain of conditionals, breathe, you got this)

โœจ OPTIONS โœจ

Okay so literally every X program out there tries to keep the same names for command-line options and arguments โ€” it's like a whole community agreement, love that for them. And any application written with the X Toolkit Intrinsics automatically accepts all of these, no extra work, no cap:

  • -display display โ€” tells it which X server to talk to. Your designated server bestie. ๐Ÿ’…
  • -geometry geometry โ€” the initial size and location of the window.
  • -bg color, -background color โ€” either one sets the color for the window background. Same vibe, two names.
  • -bd color, -bordercolor color โ€” either one sets the color for the window border.
  • -bw number, -borderwidth number โ€” either one sets the width of the window border, in pixels.
  • -fg color, -foreground color โ€” either one sets the color used for text or graphics.
  • -fn font, -font font โ€” either one sets the font used for displaying text.
  • -iconic โ€” this is the "pls don't look at me yet" option ๐Ÿซฃ. It says the user would prefer the application's windows initially not be visible, as if the windows had be immediately iconified by the user. Important caveat though: window managers may choose not to honor the application's request. Rude but true.
  • -name โ€” specifies the name under which resources for the application should be found. Super useful in shell aliases to tell apart different invocations of an application without resorting to creating links to alter the executable file name. (So much cleaner, honestly.)
  • -rv, -reverse โ€” either one says the program should simulate reverse video if possible, often by swapping the foreground and background colors. Big warning here: not all programs honor this or implement it correctly, and it's usually only used on monochrome displays. ๐Ÿ’€
  • +rv โ€” the opposite! Says the program should not simulate reverse video. Used to override any defaults, because reverse video doesn't always work properly. (Which, yeah, see above.)
  • -selectionTimeout โ€” the timeout, in milliseconds, within which two communicating applications must respond to one another for a selection request. Tick tock โฐ.
  • -synchronous โ€” requests to the X server get sent synchronously instead of asynchronously. Why d'you care? Because Xlib normally buffers requests to the server, so errors don't necessarily get reported immediately after they occur. This option turns off the buffering so the application can be debugged. > It should never be used with a working program. Seriously, not a flex, don't do it.
  • -title string โ€” the title to use for this window. This info is sometimes used by a window manager to give you some sort of header identifying the window. Main character nameplate energy ๐Ÿ‘‘.
  • -xnllanguage language[_territory_][_.codeset_] โ€” sets the language, territory, and codeset used when resolving resource and other filenames.
  • -xrm resourcestring โ€” a resource name and value to override any defaults. Also very useful for setting resources that don't have explicit command-line arguments. Sneaky-good option, iykyk.

๐ŸŽ€ RESOURCES ๐ŸŽ€

So to make tailoring applications to personal preferences easier, X gives you a whole mechanism for storing default values for program resources (background color, window title, etc.) โ€” and it's used by programs that use toolkits based on the X Toolkit Intrinsics library libXt. (Programs using the common Gtk+ and Qt toolkits use other configuration mechanisms, so don't come for them.)

Resources are specified as strings that get read in from various places when an application is run. Program components are named in a hierarchical fashion, with each node in the hierarchy identified by a class and an instance name. At the top level you've got the class and instance name of the application itself. By convention, the class name of the application is the same as the program name but with the first letter capitalized (e.g. Bitmap or Emacs), although some programs that begin with the letter ``x'' also capitalize the second letter for historical reasons. History really said "I'm built different" ๐Ÿ˜ญ.

๐ŸŒธ The precise syntax, bestie ๐ŸŒธ

Here it is, exactly this, don't freestyle:

ResourceLine    =       Comment | IncludeFile | ResourceSpec | <empty line>
Comment         =       "!" {<any character except null or newline>}
IncludeFile     =       "#" WhiteSpace "include" WhiteSpace FileName WhiteSpace
FileName        =       <valid filename for operating system>
ResourceSpec    =       WhiteSpace ResourceName WhiteSpace ":" WhiteSpace Value
ResourceName    =       [Binding] {Component Binding} ComponentName
Binding         =       "." | "*"
WhiteSpace      =       {<space> | <horizontal tab>}
Component       =       "?" | ComponentName
ComponentName   =       NameChar {NameChar}
NameChar        =       "a"-"z" | "A"-"Z" | "0"-"9" | "_" | "-"
Value           =       {<any character except null or unescaped newline>}

Reading the notation, since it's giving textbook:

  • Elements separated by a vertical bar (|) are alternatives.
  • Curly braces ({...}) mean zero or more repetitions of the stuff inside.
  • Square brackets ([...]) mean the enclosed element is optional.
  • Quotes ("...") are used around literal characters.

๐Ÿฆ‹ Include files ๐Ÿฆ‹

IncludeFile lines are interpreted by replacing the line with the contents of the specified file. The word include must be in lowercase (yes, really, lowercase or nothing ๐Ÿ’…). The filename is interpreted relative to the directory of the file in which the line occurs โ€” for example, if the filename contains no directory, or contains a relative directory specification.

If a ResourceName contains a contiguous sequence of two or more Binding characters, that sequence gets replaced with a single . character if the sequence contains only . characters โ€” otherwise the sequence gets replaced with a single * character.

A resource database never contains more than one entry for a given ResourceName. If a resource file contains multiple lines with the same ResourceName, the last line in the file is used. Last one wins, periodt.

๐Ÿงš Whitespace + escape sequences ๐Ÿงš

Any whitespace character before or after the name or colon in a ResourceSpec is ignored. But because we love a loophole:

  • To allow a Value to begin with whitespace, the two-character sequence \space (backslash followed by space) is recognized and replaced by a space character.
  • The two-character sequence \tab (backslash followed by horizontal tab) is recognized and replaced by a horizontal tab character.
  • To allow a Value to contain embedded newline characters, the two-character sequence \n is recognized and replaced by a newline character.
  • To allow a Value to be broken across multiple lines in a text file, the two-character sequence \newline (backslash followed by newline) is recognized and removed from the value.
  • To allow a Value to contain arbitrary character codes, the four-character sequence \nnn โ€” where each n is a digit character in the range of 0-7 โ€” is recognized and replaced with a single byte containing the octal value specified by the sequence.
  • Finally, the two-character sequence \\ is recognized and replaced with a single backslash.

๐ŸŒˆ How lookup actually works ๐ŸŒˆ

When an application looks for the value of a resource, it specifies a complete path in the hierarchy, with both class and instance names. But resource values are usually given with only partially specified names and classes, using pattern-matching constructs:

  • An asterisk (*) is a loose binding and represents any number of intervening components, including none.
  • A period (.) is a tight binding and separates immediately adjacent components.
  • A question mark (?) matches any single component name or class.
A database entry cannot end in a loose binding โ€” the final component (which cannot be ?) must be specified. No dangling asterisks, bestie.

The lookup algorithm searches the resource database for the entry that most closely matches (is most specific for) the full name and class being queried. When more than one database entry matches the full name and class, precedence rules select just one.

The full name and class get scanned from left to right (highest level in the hierarchy to lowest), one component at a time. At each level, the corresponding component and/or binding of each matching entry is determined, and those matching components and bindings are compared according to the precedence rules. Each rule is applied at each level, before moving to the next level, until a rule selects a single entry over all others. The rules, in order of precedence:

  1. An entry that contains a matching component (whether name, class, or ?) takes precedence over entries that elide the level โ€” that is, entries that match the level in a loose binding.
  2. An entry with a matching name takes precedence over both entries with a matching class and entries that match using ?. An entry with a matching class takes precedence over entries that match using ?.
  3. An entry preceded by a tight binding takes precedence over entries preceded by a loose binding.

๐Ÿ‘‘ Where the resources come from ๐Ÿ‘‘

Programs based on the X Toolkit Intrinsics obtain resources from the following sources (other programs usually support some subset of these sources):

  • RESOURCE_MANAGER root window property โ€” any global resources that should be available to clients on all machines should be stored in the RESOURCE_MANAGER property on the root window of the first screen, using the xrdb program. This is frequently taken care of when the user starts up X through the display manager or xinit. Basically, it's already handled, you're welcome ๐Ÿ’–.
  • SCREEN_RESOURCES root window property โ€” any resources specific to a given screen (e.g. colors) that should be available to clients on all machines should be stored in the SCREEN_RESOURCES property on the root window of that screen. The xrdb program will sort resources automatically and place them in RESOURCE_MANAGER or SCREEN_RESOURCES, as appropriate. Sorting queen ๐ŸŽ€.
  • application-specific files โ€” directories named by the environment variable XUSERFILESEARCHPATH or the environment variable XAPPLRESDIR (which names a single directory and should end with a / on POSIX systems), plus directories in a standard place (usually under /usr/share/X11/, but this can be overridden with the XFILESEARCHPATH environment variable) are searched for application-specific resources. For example, application default resources are usually kept in /usr/share/X11/app-defaults/. See the X Toolkit Intrinsics - C Language Interface manual for details.

๐ŸŒธ XENVIRONMENT ๐ŸŒธ

Okay so bestie, if you want user- and machine-specific resources to get loaded by all the applications, you set the XENVIRONMENT environment variable to the name of a resource file. If that variable is not defined, the system looks for a file named $HOME/.Xdefaults-hostname instead, where hostname is the name of the host where the application is executing. Cute, right? ๐Ÿ’–

๐ŸŽ€ -xrm resourcestring ๐ŸŽ€

You can also specify resources straight from the command line. The resourcestring is a single resource name and value, like the ones shown above. Quick note, because the shell is gonna shell: if the string contains characters interpreted by the shell (e.g., asterisk *), they must be quoted. And yes, you can give any number of -xrm arguments on the command line. Slay. โœจ

Program resources are organized into groups called classes, so collections of individual resources (each of which are called instances) can be set all at once. By convention, the instance name of a resource begins with a lowercase letter and the class name begins with an upper case letter. Multiple word resources are concatenated with the first letter of the succeeding words capitalized. Applications written with the X Toolkit Intrinsics will have at least these resources:

  • background (class Background) โ€” this resource specifies the color to use for the window background. ๐ŸŒˆ
  • borderWidth (class BorderWidth) โ€” this resource specifies the width in pixels of the window border. ๐Ÿ“
  • borderColor (class BorderColor) โ€” this resource specifies the color to use for the window border. ๐ŸŽ€

Most applications using the X Toolkit Intrinsics also have the resource foreground (class Foreground), specifying the color to use for text and graphics within the window. Iconic. ๐Ÿ‘‘

By combining class and instance specifications, application preferences can be set quickly and easily. Users of color displays will frequently want to set Background and Foreground classes to particular defaults. Specific color instances such as text cursors can then be overridden without having to define all of the related resources. For example:

bitmap*Dashed:  off
XTerm*cursorColor:  gold
XTerm*multiScroll:  on
XTerm*jumpScroll:  on
XTerm*reverseWrap:  on
XTerm*curses:  on
XTerm*Font:  6x10
XTerm*scrollBar: on
XTerm*scrollbar*thickness: 5
XTerm*multiClickTime: 500
XTerm*charClass:  33:48,37:48,45-47:48,64:48
XTerm*cutNewline: off
XTerm*cutToBeginningOfLine: off
XTerm*titeInhibit:  on
XTerm*ttyModes:  intr ^c erase ^? kill ^u
XLoad*Background: gold
XLoad*Foreground: red
XLoad*highlight: black
XLoad*borderWidth: 0
emacs*Geometry:  80x65-0-0
emacs*Background:  rgb:5b/76/86
emacs*Foreground:  white
emacs*Cursor:  white
emacs*BorderColor:  white
emacs*Font:  6x10
xmag*geometry: -0-0
xmag*borderColor:  white

If these resources were stored in a file called .Xresources in your home directory, they could be added to any existing resources in the server with the following command:

% xrdb -merge $HOME/.Xresources

This is frequently how user-friendly startup scripts merge user-specific defaults into any site-wide defaults. All sites are encouraged to set up convenient ways of automatically loading resources. See the Xlib manual section Resource Manager Functions for more information. ๐Ÿซถ

โœจ ENVIRONMENT โœจ

  • DISPLAY โ€” this is the only mandatory environment variable. It must point to an X server. See section "Display Names" above. ๐Ÿ’…
  • XAUTHORITY โ€” this must point to a file that contains authorization data. The default is $HOME/.Xauthority. See Xsecurity(7), xauth(1), xdm(1), Xau(3). ๐Ÿ”
  • ICEAUTHORITY โ€” this must point to a file that contains authorization data. The default is $HOME/.ICEauthority.
  • LC_ALL, LC_CTYPE, LANG โ€” the first non-empty value among these three determines the current locale's facet for character handling, and in particular the default text encoding. See locale(7), setlocale(3), locale(1). ๐ŸŒ
  • XMODIFIERS โ€” this variable can be set to contain additional information important for the current locale setting. Typically set to @im=<input-method> to enable a particular input method. See XSetLocaleModifiers(3).
  • XLOCALEDIR โ€” this must point to a directory containing the locale.alias file and Compose and XLC_LOCALE file hierarchies for all locales. The default value is /usr/share/X11/locale.
  • XENVIRONMENT โ€” this must point to a file containing X resources. The default is $HOME/.Xdefaults-<hostname>. Unlike $HOME/.Xresources, it is consulted each time an X application starts. โญ
  • XFILESEARCHPATH โ€” this must contain a colon separated list of path templates, where libXt will search for resource files. The default value consists of:
/etc/X11/%L/%T/%N%C%S:\
/etc/X11/%l/%T/%N%C%S:\
/etc/X11/%T/%N%C%S:\
/etc/X11/%L/%T/%N%S:\
/etc/X11/%l/%T/%N%S:\
/etc/X11/%T/%N%S:\
/usr/share/X11/%L/%T/%N%C%S:\
/usr/share/X11/%l/%T/%N%C%S:\
/usr/share/X11/%T/%N%C%S:\
/usr/share/X11/%L/%T/%N%S:\
/usr/share/X11/%l/%T/%N%S:\
/usr/share/X11/%T/%N%S:\
/usr/lib/X11/%L/%T/%N%C%S:\
/usr/lib/X11/%l/%T/%N%C%S:\
/usr/lib/X11/%T/%N%C%S:\
/usr/lib/X11/%L/%T/%N%S:\
/usr/lib/X11/%l/%T/%N%S:\
/usr/lib/X11/%T/%N%S

A path template is transformed to a pathname by substituting:

  • %D => the implementation-specific default path
  • %N => name (basename) being searched for
  • %T => type (dirname) being searched for
  • %S => suffix being searched for
  • %C => value of the resource "customization" (class "Customization")
  • %L => the locale name
  • %l => the locale's language (part before '_')
  • %t => the locale's territory (part after '_' but before '.')
  • %c => the locale's encoding (part after '.')
  • XUSERFILESEARCHPATH โ€” this must contain a colon separated list of path templates, where libXt will search for user dependent resource files. The default value is:
$XAPPLRESDIR/%L/%N%C:\
$XAPPLRESDIR/%l/%N%C:\
$XAPPLRESDIR/%N%C:\
$HOME/%N%C:\
$XAPPLRESDIR/%L/%N:\
$XAPPLRESDIR/%l/%N:\
$XAPPLRESDIR/%N:\
$HOME/%N

$XAPPLRESDIR defaults to $HOME, see below.

Same substitution rules, bestie:

  • %D => the implementation-specific default path
  • %N => name (basename) being searched for
  • %T => type (dirname) being searched for
  • %S => suffix being searched for
  • %C => value of the resource "customization" (class "Customization")
  • %L => the locale name
  • %l => the locale's language (part before '_')
  • %t => the locale's territory (part after '_' but before '.')
  • %c => the locale's encoding (part after '.')
  • XAPPLRESDIR โ€” this must point to a base directory where the user stores the application dependent resource files. The default value is $HOME. Only used if XUSERFILESEARCHPATH is not set. ๐Ÿ“
  • XKEYSYMDB โ€” this must point to a file containing nonstandard keysym definitions. The default value is /usr/share/X11/XKeysymDB.
  • XCMSDB โ€” this must point to a color name database file. The default value is /usr/lib/X11/Xcms.txt. ๐ŸŽจ
  • RESOURCE_NAME โ€” this serves as main identifier for resources belonging to the program being executed. It defaults to the basename of pathname of the program.
  • SESSION_MANAGER โ€” denotes the session manager to which the application should connect. See xsm(1), rstart(1).
  • XF86BIGFONT_DISABLE โ€” setting this variable to a non-empty value disables the XFree86-Bigfont extension. This extension is a mechanism to reduce the memory consumption of big fonts by use of shared memory. ๐Ÿงš

And these variables influence the X Keyboard Extension:

  • XKB_FORCE
  • XKB_DISABLE
  • XKB_DEBUG
  • _XKB_CHARSET
  • _XKB_LOCALE_CHARSETS
  • _XKB_OPTIONS_ENABLE
  • _XKB_LATIN1_LOOKUP
  • _XKB_CONSUME_LOOKUP_MODS
  • _XKB_CONSUME_SHIFT_AND_LOCK
  • _XKB_IGNORE_NEW_KEYBOARDS
  • _XKB_CONTROL_FALLBACK
  • _XKB_COMP_LED
  • _XKB_COMP_FAIL_BEEP

๐ŸŒŸ EXAMPLES ๐ŸŒŸ

The following is a collection of sample command lines for some of the more frequently used commands. For more information on a particular command, please refer to that command's manual page. ๐Ÿ’–

%  xrdb $HOME/.Xresources
%  xmodmap -e "keysym BackSpace = Delete"
%  mkfontdir /usr/local/lib/X11/otherfonts
%  xset fp+ /usr/local/lib/X11/otherfonts
%  xmodmap $HOME/.keymap.km
%  xsetroot -solid 'rgbi:.8/.8/.8'
%  xset b 100 400 c 50 s 1800 r on
%  xset q
%  twm
%  xmag
%  xclock -geometry 48x48-0+0 -bg blue -fg white
%  xeyes -geometry 48x48-48+0
%  xbiff -update 20
%  xlsfonts '*helvetica*'
%  xwininfo -root
%  xdpyinfo -display joesworkstation:0
%  xhost -joesworkstation
%  xrefresh
%  xwd | xwud
%  bitmap companylogo.bm 32x32
%  xcalc -bg blue -fg magenta
%  xterm -geometry 80x66-0-0 -name myxterm $*

๐Ÿ’€ DIAGNOSTICS ๐Ÿ’€

Okay so, a wide variety of error messages get generated from various programs โ€” that's just the X life. The default error handler in Xlib (also used by many toolkits) uses standard resources to construct diagnostic messages when errors occur. The defaults for these messages are usually stored in /usr/share/X11/XErrorDB. If that file is not present, error messages will be rather terse and cryptic, which is giving "mystery note from the void" energy. ๐Ÿ˜ญ

When the X Toolkit Intrinsics encounter errors converting resource strings to the appropriate internal format, no error messages are usually printed. This is convenient when it is desirable to have one set of resources across a variety of displays (e.g. color vs. monochrome, lots of fonts vs. very few, etc.), although it can pose problems for trying to determine why an application might be failing. So yes, silence can be a whole vibe until it isn't. ๐Ÿ™ˆ

This behavior can be overridden by setting the StringConversionWarnings resource.

To force the X Toolkit Intrinsics to always print string conversion error messages, the following resource should be placed in the file that gets loaded onto the RESOURCE_MANAGER property using the xrdb program (frequently called .Xresources or .Xres in the user's home directory):

*StringConversionWarnings: on

To have conversion messages printed for just a particular application, the appropriate instance name can be placed before the asterisk:

xterm*StringConversionWarnings: on

๐ŸŒˆ SEE ALSO โœจ

Manual pages, bestie โ€” the whole friend group:

Also: Xlib - C Language X Interface, and X Toolkit Intrinsics - C Language Interface.

Those specifications, and additional specifications & documentation for the X Window System may also be found in /usr/share/doc or on the X.Org Foundation website at http://www.x.org/releases/current/doc/.


๐ŸŽ€ TRADEMARKS ๐ŸŽ€

X Window System is a trademark of The Open Group. Noted, protected, iconic. ๐Ÿ‘‘


๐Ÿ‘‘ AUTHORS ๐Ÿ‘‘

A cast of thousands, literally. Releases 6.7 and later are brought to you by the X.Org Foundation. The names of all people who made it a reality will be found in the individual documents and source files.

Releases 6.6 and 6.5 were done by The X.Org Group. Release 6.4 was done by The X Project Team. The Release 6.3 distribution was from The X Consortium, Inc. The staff members at the X Consortium responsible for that release were: Donna Converse (emeritus), Stephen Gildea (emeritus), Kaleb Keithley, Matt Landau (emeritus), Ralph Mor (emeritus), Janet O'Halloran, Bob Scheifler, Ralph Swick, Dave Wiggins (emeritus), and Reed Augliere.

The X Window System standard was originally developed at the Laboratory for Computer Science at the Massachusetts Institute of Technology, and all rights thereto were assigned to the X Consortium on January 1, 1994. X Consortium, Inc. closed its doors on December 31, 1996. All rights to the X Window System have been assigned to The Open Group.


And that's the whole X(7) saga, bestie. The footer is serving X Version 11, xorg-docs 1.7.3, page X(7) โ€” version energy immaculate, no more notes, periodt. ๐Ÿ’…โœจ

๐Ÿ“ฆ where this page comes from