Guide to X11/Starting Programs

From Wikibooks, open books for an open world
Jump to: navigation, search

Authors · History · Print · License

Introduction · Configuring · Building · Starting Sessions · Starting Programs · Fonts · Window Managers · Xt Clients · Political History · References and Links

Supplements: Commands

Edit this template

Starting Programs[edit]

The traditional Unix method of starting a program is call it from the shell by entering its name on the command line. For example:

$ emacs

At the beginning of the X Window System, the method to start an X11 client was essentially the same. You would always have an XTerm open, so you could enter commands to open Emacs, Netscape, and other XTerms. Of course, this meant that if you closed (or xkilled) an XTerm, you would "hang up" all programs started from it, thus causing them to quit and disappear suddenly. So you had to remember to leave open the XTerm from which you started the clients.

Such behaviour is the function of launching programs in the foreground, which makes it dependent on the shell/terminal window (xterm, rxvt, or some other) being open and working.

To launch multiple windowed programs independent of the shell window (that is, in the background), attach an ampersand at the end of each command:

$ xclock &

Outside the shell[edit]

Some window managers added a feature called the minicli, for MINIature Command LIne. You choose "Run Command" from some menu, then type the name of a program, such as "emacs". This solved the problem of having extra XTerms (or Konsoles, et cetera) open just to start some programs. However, it introduced another problem: some programs print error messages to the terminal, and you might need to retrieve the error message if you wonder why your program is crashing or not starting. The solution is to log to some file, such as ~/.xsession-errors, when starting your session. Most implementations of X do this automatically.

Many window managers also allow to start programs from menus. However, different window managers have different methods of configuration. There are some attempts at a solution such that you can use the same menu in different window managers. The GNOME and KDE desktop environments currently use a common *.desktop file format to indicate a menu item.

KDE typically provides a K menu in the lower left corner of the screen. GNOME typically provides menus like "Applications" in the upper left corner. Both environments can be customised. Some window managers, like twm and IceWM, let you click on the desktop background to summon the menu.

Specifying window geometry[edit]

In X, it's typically easy to set a program window's size and position by specifying the -geometry parameter with the following value syntax —

XOFF or horizontal axis handles top-to-bottom and reverse directions; YOFF or vertical axis is for left-to right and reverse directions. Plus (+) and minus (-) signs before XOFF/YOFF correlate to edges of origin: + is the amount of pixels off the left/top edge; - is the number of pixels off the right/bottom edge.

Example with xeyes:

$ xeyes -geometry 100x100-37+50 &

— Where xeyes opens with the size of 100x100 pixels, at 37 pixels from right– and 50 pixels from top of the screen. The ampersand (&) frees xeyes from the terminal.

The -geometry parameter can be used both in the shell and from within the X menu system and menu systems of other windowing environments.


Setting window geometry might not or won't work with programs that don't recognise the specification, such as Mozilla Firefox and Wine; Firefox uses its own command-line settings, and Wine launches more than one window with at least one of them not being native to X.

While most window managers and desktop environments support the specification, some might not.

{{TODO|todonote=Describe how to use the network. Describe Xlib}