From: dbl@ics.com (David B. Lewis) Newsgroups: comp.windows.x,news.answers,comp.answers Subject: comp.windows.x Frequently Asked Questions (FAQ) 2/6 Date: 11 Apr 1995 13:36:26 GMT Organization: ICS Approved: news-answers-request@MIT.Edu Expires: Sun, 14 May 1995 00:00:00 GMT Message-ID: <3me0kq$qeq@ics.com> Reply-To: faq%craft@uunet.uu.net (X FAQ maintenance address) Summary: useful information about the X Window System Archive-name: x-faq/part2 Last-modified: 1995/04/10 ---------------------------------------------------------------------- Subject: 17) Can I save the state of my X session, like toolplaces does? Although no known window manager directly supports such a feature (olvwm and swm may come close) -- which may be equivalent to writing out a .xinitrc or .xsession file naming the geometry and WM_COMMAND of each application -- there is a contributed application which does much of what you are looking for, although it is not as complete as the SunView program toolplaces. Look for the application "xplaces" on an archive-server near you. There are several versions of this program floating around; look for a recent vintage. [10/90] Some new pseudo session-managers such as HP's vuewm provide for the saving of sessions including information on the geometry of currently-running applications and the resource database. [Bjxrn Stabell (bjoerns@staff.cs.uit.no); 3/93.] In Release 6 a new session management protocol was defined, called XSMP (see doc/specs/SM), for telling applications when to save their internal state and for managing user dialog during the save. R6 contains a very simple session manager that exercises this protocol in the workInProgress directory; look for xsm. R6 also added a new shell widget class to Xt to make it easier to write applications that react to messages from a session manager. The window managers still have to do the work to save the window positions. [Dave Wiggins (dpw@x.org); 5/94.] ---------------------------------------------------------------------- Subject: 18) How do I use another window manager with DEC's session manager? DEC's session manager will start dxwm up by default. To override this, add to your .Xdefaults file something like this line, naming the full pathname: sm.windowManagerName: /wherever/usr/bin/X11/your_favorite_wm ---------------------------------------------------------------------- Subject: 19) How do I change the keyboard auto-repeat rate? You can turn auto-repeat on or off by using "xset r on|off". The base X11 protocol, doesn't provide for varying the auto-repeat rate, which is a capability not supported by all systems. Some pre-R6 servers may provide command-line flags to set the rate at start-up time. If you have control over server start-up (see the man pages for xinit and xdm), you can invoke the server with the chosen settings; for example, you can start the R5 Xsun sample server with the options "-ar1 350 -ar2 30" to reduce the sensitivity of the keyboard. The R6 X Keyboard Extension provides a vendor-independent way to control repeat delay and rate. ---------------------------------------------------------------------- Subject: 20) How do I remap the keys on my keyboard to produce a string? There is no method of arranging for a particular string to be produced when you press a particular key. The xmodmap client, which is useful for moving your CTRL and ESC keys to useful places, just rearranges keys and does not do "macro expansion." Some (few) clients, including xterm and several X-based editors, accept a translation resource such as: xterm*VT100.Translations: #override \ F1: string("setenv DISPLAY unix:0") which permits the shorthand F1 to be pressed to reset the display locally within an xterm; it takes effect for new xterm clients. To include control characters in the string, use \nnn, where nnn is the octal encoding of the control character you want to include. Window managers, which could provide this facility, do not yet; nor has a special "remapper" client been made available. ---------------------------------------------------------------------- Subject: 21) How do I make a screendump or print my application (including menus)? The xwd client in the X11 distributions can be used to select a window or the background. It produces an XWD-format file of the image of that window. The file can be post-processed into something useful or printed with the xpr client and your local printing mechanism. To print a screendump including a menu or other object which has grabbed the pointer, you can use this command: csh% sleep 10; xwd -root > output.xwd & and then spend 10 seconds or so setting up your screen; the entire current display will be saved into the file output.xwd. Note that xwd also has an undocumented (before R5) -id flag for specifying the window id on the command-line. [There are also unofficial patches on ftp.x.org to xwd for specifying the delay and the portion of the screen to capture.] Two publicly-available programs which allow interactive definition of arbitrary portions of the display and built-in delays are xsnap and xgrabsc. xgrabsc is a free screendump program that provides multiple selection styles and several output formats. Selection styles include xwd-style point and click, dragging a rectangle over an arbitrary portion of the screen, timed snapshots for menu capturing, and keyboard-based selection. Output formats are xwd, XPM (v1 and 2), bitmap, puzzle, and monochrome, greyscale, and color PostScript. PostScript output can be in ready-to-print true-scale form or encapsulated for inclusion in Frame, xfig, and other programs that accept EPS graphics. There are several versions of xgrabsc; version 2.3, available on ftp.x.org [9/93] is the most recent. xgrab, part of the package, is an interactive front-end to xgrabsc. xwpick (formerly xpick) (by Evgeni Chernyaev (chernaev@mx.ihep.su)) is available on ftp.x.org as xwpick-2.20.tar.Z; it creates Level 2 color PostScript dumps of X screens and can generate GIF, PICT, and other formats. PostScript output is very small. xwpick runs under VMS and Unix systems. xsnap includes some asnap features and supersedes it; it also renders XPM output [version unknown]. It is available on ftp.x.org or avahi.inria.fr; see xsnap-pl2.tar.Z. A screen-dump and merge/edit program combining features of xwd and xpr is available from vernam.cs.uwm.edu as xdump1.0.tar.Z. Information: soft-eng@cs.uwm.edu. xprint, by Alberto Accomazzi (alberto@cfa.harvard.edu) is available from cfa0.harvard.edu (128.103.40.1) as /pub/wipl/xprint.export-2.1.tar.Z. The package allows users to create encapsulated color PostScript files which will print on any PostScript Level-1 compliant printer (black and white or color). To post-process the xwd output of some of these tools, you can use xpr, which is part of the X11 distribution (moved to contrib in R6). Also on several archives are xwd2ps and "import" (formerly XtoPS), which produce Encapsulated PostScript with trimmings suitable for use in presentations (see ftp.x.org:contrib/xwd2ps.tar.Z and contrib/applications/ImageMagick/ImageMagick3.4.tar.Z). Also useful is the PBMPLUS/Netpbm package on many archive servers; and the Xim package contains Level 2 color PostScript output. The xv program can grab a portion of the X display, manipulate it, and save it in one of the available formats. ImageMagick has similar capabilities. Also: Bristol Technology (info@bristol.com, 203-438-6969) offers Xprinter, an Xlib API for PostScript and PCL printers; a demo is in ftp.bristol.com:/pub/Demos/DE. ColorSoft 9619-459-8500) offers OPENprint; the package includes a screen-capture facility, image-processing, and support for PostScript and non-PostScript printers. Some vendors' implementations of X (e.g. DECWindows and OpenWindows) include session managers or other desktop programs which include "print portion of screen" or "take a snapshot" options. Some platforms also have tools which can be used to grab the frame-buffer directly; the Sun systems, for example, have a 'screendump' program which produces a Sun raster file. Some X terminals have local screen-dump utilities to write PostScript to a local serial printer. Some vendors' implementations of lpr (e.g. Sony) include direct support for printing xwd files, but you'll typically need some other package to massage the output into a useful format which you can get to the printer. ---------------------------------------------------------------------- Subject: 22) How do I make a color PostScript screendump of the X display? If you need color PostScript in particular, you can - grab the screen-image using a program which can produce color PostScript, such as xgrabsc, xprint, xwpick, and xv - grab the screen-image using xwd and post-process xwd into color PS. You can do this using xwd2ps or the "import" (formerly XtoPS) program from the ImageMagick distribution. The PBMPLUS/Netpbm package is also good for this, as is the Xim package. Also: Another alternative is to use the Xprinter product from Bristol Technology, Inc. which provides PostScript output using the Xlib API. Send email to info@bristol.com for details. ---------------------------------------------------------------------- Subject: 23) How do I make a screendump including the X cursor? This can't be done unless the X server has been extended. Consider instead a system-dependent mechanism for, e.g., capturing the frame-buffer. ---------------------------------------------------------------------- Subject: 24) How do I convert or view Mac/TIFF/GIF/Sun/PICT/img/FAX images in X? The likeliest program is an incarnation of Jef Poskanzer's useful++ Portable Bitmap Toolkit, which includes a number of programs for converting among various image formats. It includes support for many types of bitmaps, gray-scale images, and full-color images. PBMPLUS has been updated recently; the most recent version [12/91] is on ftp.x.org in contrib/pbmplus10dec91.tar.Z. Netpbm is based on the PBMPLUS 10dec91 release, with many additions and improvements. It is intended to be portable to many platforms while allowing for conversion of images between a variety of formats. The latest sources are on several sites, including wuarchive.wustl.edu (128.252.135.4) and peipa.essex.ac.uk (155.245.115.161). Contact oliver@fysik4.kth.se to be added to the netpbm mailing list. Another tool is San Diego Supercomputing Center's IMtools ('imconv' in particular), which packages the functionality of PBM into a single binary. It's available anonymous ftp from sdsc.edu (132.249.20.22). Useful for viewing and converting some image-formats is Jim Frost's xloadimage; the most recent [11/93] is on ftp.x.org in contrib/xloadimage.4.1.tar.Z. Graeme Gill's updates to an earlier version of xloadimage are also on ftp.x.org; see xli.README and xli.tar.Z.uu; version 1.15 was released 7/93. xv (X Image Viewer), written by John Bradley (xv@devo.dccs.upenn.edu for XV questions), can read and display pictures in Sun Raster, PGM, PBM, PPM, X11 bitmap, TIFF, GIF and JPEG. It can manipulate on the images: adjust, color, intensity, contrast, aspect ratio, crop). It can save images in all of the aforementioned formats plus PostScript. It can grab a portion of the X display, manipulate on it, and save it in one of the available formats. The program was updated 5/92; see the file contrib/xv-2.21.tar.Z on ftp.x.org. Version 3.10a [3/95] is distributed as shareware. New versions are on ftp.cis.upenn.edu in pub/xv. The Fuzzy Pixmap Manipulation, by Michael Mauldin (mlm@nl.cs.cmu.edu). Conversion and manipulation package, similar to PBMPLUS. Version 1.0 available via FTP as nl.cs.cmu.edu:/usr/mlm/ftp/fbm.tar.Z, uunet.uu.net:pub/fbm.tar.Z, and ucsd.edu:graphics/fbm.tar.Z. The Img Software Set, by Paul Raveling , reads and writes its own image format, displays on an X11 screen, and does some image manipulations. Version 1.3 is available via FTP on ftp.x.org as contrib/img_1.3.tar.Z, along with large collection of color images. The Utah RLE Toolkit is a conversion and manipulation package similar to PBMPLUS. Available via FTP as cs.utah.edu:pub/urt-*, weedeater.math.yale.edu:pub/urt-*, and freebie.engin.umich.edu:pub/urt-*. Xim, The X Image Manipulator, by Philip Thompson, does essential interactive displaying, editing, filtering, and converting of images. There is a version in the X11R4 contrib area; but a more recent version (using R4 and Motif 1.1) is available from gis.mit.edu (18.80.1.118). Xim reads/writes gif, xwd, xbm, tiff, rle, xim, (writes level 2 eps) and other formats and also has a library and command-line utilities for building your own applications. ImageMagick by cristy@dupont.com is an X11 package for display and interactive manipulation of images. Includes tools for image conversion, annotation, compositing, animation, and creating montages. ImageMagick can read and write many of the more popular image formats (JPEG, TIFF, PNM, PostScript, ...). Available via FTP from ftp.x.org as contrib/applications/ImageMagick/ImageMagick3.4.tar.Z. [12/94] xtiff is a tool for viewing a TIFF file in an X window. It was written to handle as many different kinds of TIFF files as possible while remaining simple, portable and efficient. xtiff illustrates some common problems with building pixmaps and using different visual classes. It is distributed as part of Sam Leffler's libtiff package and it is also available on ftp.x.org and comp.sources.x. [dbs@decwrl.dec.com,10/90] xtiff 2.0 was announced in 4/91; it includes Xlib and Xt versions. A version of Lee Iverson's (leei@McRCIM.McGill.EDU) image-viewing tool is available as contrib/vimage-0.9.3.tar.Z on ftp.x.org. The package also includes an ImageViewPort widget and a FileDialog widget. [12/91;5/92] The Andrew User Interface System (version 5.2 and later) provides an image inset which can view many image formats. Like all Andrew insets, an image can be incorporated in a a document or sent in email via the MIME standard. The following formats can be read: Sunraster, GIF, Xbitmap, TIFF, Xpixmap, JPEG, PBM, XWD. The LUG (Libreria de Utilidades Graficas) is a library of subroutines offering several routines for the manipulation of images in several different formats. The distribution includes viewers for several different platforms. The distribution is on telva.ccu.uniovi.es (156.35.31.31): /uniovi/mathdept/src/liblug-1.0.1.tar.gz. The X Image Extension (XIE), an X Consortium standard in R6, provides facilities for transmitting displaying fax (G3, G4), TIFF, and JPEG images. [some material from Larry Carroll (larryc@poe.jpl.nasa.gov), 5/91] ---------------------------------------------------------------------- Subject: 25) Where can I get an X-based 3-D object viewer? xmgf by Paul Hoad (P.Hoad@ee.surrey.ac.uk) is an interactive tool for viewing 2D and 3D objects typically in gf/OFF/NFF/IGRIP/MINICAD/SLA/DXF format Sources are on ftp.x.org. Version 1.9.1 became available 12/93. x3d is a V.Fast 3D Object viewer for X it needs no special hardware or or widget libraries other that X and is optimized for speed. XGobi can be used to to view such data. VOGLE can be used to to view such data. ---------------------------------------------------------------------- Subject: 26) How can I change the titlebar of my terminal window? The solution involves sending an escape sequence to xterm which will cause it to update the property which the window manager relies upon for the string which appears in the window titlebar. A solution is as easy as typing this in an xterm running a shell: echo "ESC]2;TEXT^G" where ESC is the escape key, TEXT is the string you wish to have displayed, and ^G is a Control-G (the BEL character). Note that the semi-colon is demanded by more recent versions of xterm. (Some shells and editors need an escape character, typically ^V, before accepting control characters literally.) Here is a more complicated csh alias which changes the titlebar to the current working directory when you change directories: alias newcd 'cd \!*; echo -n ESC]2\;$cwd^G' (for other shells e.g. ksh you will need to write a function for cd to print this value). The digit '2' in these strings indicates to xterm that it should change only the title of the window; to change both the title and the name used in the icon, use the digit '0' instead, and use '1' to change only the icon name. Note: another way to do this, which prevents an incorrect display of the local directory if a modified `cd` is used in a subshell, is to wrap the escape sequences into the PS1 prompt itself. If you are using DECterm, the sequence is "ESC]21;TEXTESC\". For an HPterm, you need "ESC&f0kDTEXT". Here is the number of characters in TEXT, as a decimal number in ASCII. To change the icon name, use "ESC&f-1kDTEXT". [thanks to Karsten Spang (krs@kampsax.dk); 12/94] ---------------------------------------------------------------------- Subject: 27) Where can I find the xterm control sequences? The best source of such information is in your R5/R6 sources in the file ctlseqs.ms (R6: xc/doc/specs/xterm/ctlseqs.ms); a PostScript version is in your R5 sources in mit/hardcopy/clients/ctlseqs.PS.Z and your R6 sources in xc/doc/hardcopy/xterm/ctlseqs.PS.Z. Both editions of O'Reilly's Volume 3, the X User's Guide, include an R5 version of the control sequences. Other good sources of information include the R4 version of that document and also the file in the R4 sources called mit/clients/xterm/ctlseq2.txt, a compilation put together by Skip Montanaro (GE CR&D) listing the VT100 sequences. It dates from R3 but is fairly accurate. A hardcopy version was published in the December 1989 XNextEvent (the XUG newsletter). In a pinch, a VT100 manual will do. [last updated 10/91] ---------------------------------------------------------------------- Subject: 28) How can I use characters above ASCII 127 in xterm ? In order to use special characters such as the o-umlaut, you need to "stty pass8" (you may need "stty -parenb -istrip cs8" on strictly-POSIX systems) but also to use a charcell ISO8859 font, such as XTerm*font: -*-*-medium-r-normal-*-*-130-*-*-c-*-iso8859-1 XTerm*boldfont: -*-*-bold-r-normal-*-*-130-*-*-c-*-iso8859-1 [The family is intentionally unspecified in this example.] In addition, you may want to set this in your shell: setenv LC_CTYPE iso_8859_1 For a given character above 127, you can determine the key to use with the Alt modifier by finding the equivalent character below 127 (try using `man ascii`). For example, o-umlaut (v) is Alt-v and the section character (') is Alt-'. [thanks to Greg Holmberg (greg%thirdi@uunet.uu.net) and Stephen Gildea (gildea@x.org); 6/92] ---------------------------------------------------------------------- Subject: 29) Why are my xterm menus so small (sic) ? You are probably setting the geometry small accidentally. If you give a resource specification like this: xterm*geometry: 80x24 then you are asking for all widgets under xterm to have their geometry set to 80x24. For the main window, this is OK, as it uses characters for its size. But its popup menus don't; they are in pixels and show up small. To set only the terminal widget to have the specified geometry, name it explicitly: xterm*VT100.geometry: 80x24 ---------------------------------------------------------------------- Subject: 30) How can I print the current X selection? You could paste it into an xterm after executing the lpr command. However, a program by Richard Hesketh (rlh2@ukc.ac.uk) specifically for manipulating the selection will help; e.g. % xselection PRIMARY | lpr finds the primary selection and prints it. This command can be placed in a window-manager menu or in shell-scripts. xselection also permits the setting of the selection and other properties. A version is on ftp.x.org. Also available is ria.ccs.uwo.ca:pub/xget_selection.tar.Z, which can be adapted to do this. ---------------------------------------------------------------------- Subject: 31) Where are the resources loaded from? The resources of a widget are filled in from the following places (from highest priority to lowest priority): 1. Args passed at creation time. 2. Command line arguments. 3. User's per host defaults file 4. User's defaults file. 5. User's per application default file. 6. System wide per application default file. Note that 2-6 are read only once on application startup. The result of steps 3-6 is a single resource database used for further queries. Please see the comp.windows.x.intrinsics FAQ, from which this information is abstracted, for a full explanation of how to specify the location of files; see also a good book on Xt, such as ORA's Volume 4, the Asente/Swick book, or the Xt documentation, for more information. ---------------------------------------------------------------------- Subject: 32) How does Xt use environment variables in loading resources? You can use several environment variables to control how resources are loaded for your Xt-based programs -- XFILESEARCHPATH, XUSERFILESEARCHPATH, and XAPPLRESDIR. These environment variables control where Xt looks for application-defaults files as an application is initializing. Xt loads at most one app-defaults file from the path defined in XFILESEARCHPATH and another from the path defined in XUSERFILESEARCHPATH. XAPPLRESDIR existed in R3 and before. As of R4, the Xt developers added the more sophisticated *SEARCHPATH mechanism, but left XAPPLRESDIR in place to avoid breaking existing software. Set XFILESEARCHPATH if software is installed on your system in such a way that app-defaults files appear in several different directory hierarchies. Suppose, for example, that you are running Sun's Open Windows, and you also have some R4 X applications installed in /usr/lib/X11/app-defaults. You could set a value like this for XFILESEARCHPATH, and it would cause Xt to look up app-defaults files in both /usr/lib/X11 and /usr/openwin/lib (or wherever your OPENWINHOME is located): setenv XFILESEARCHPATH /usr/lib/X11/%T/%N:$OPENWINHOME/lib/%T/%N The value of this environment variable is a colon-separated list of pathnames. The pathnames contain replacement characters as follows (see XtResolvePathname()): %N The value of the filename parameter, or the application's class name. %T The value of the file "type". In this case, the literal string "app-defaults" %C customization resource (R5/R6 only) %D site default value for XFILESEARCHPATH (R6 only) %S Suffix. None for app-defaults. %L Language, locale, and codeset (e.g. "ja_JP.EUC") %l Language part of %L (e.g. "ja") %t The territory part of the display's language string %c The codeset part of the display's language string Let's take apart the example. Suppose the application's class name is "Myterm". Also, suppose Open Windows is installed in /usr/openwin. (Notice the example omits locale-specific lookup.) /usr/lib/X11/%T/%N means /usr/lib/X11/app-defaults/Myterm $OPENWINHOME/lib/%T/%N means /usr/openwin/lib/app-defaults/Myterm As the application initializes, Xt tries to open both of the above app-defaults files, in the order shown. As soon as it finds one, it reads it and uses it, and stops looking for others. The effect of this path is to search first in /usr/lib/X11, then in /usr/openwin. Let's consider another example. This time, let's set XUSERFILESEARCHPATH so it looks for the file Myterm.ad in the current working directory, then for Myterm in the directory ~/app-defaults. setenv XUSERFILESEARCHPATH ./%N.ad:$HOME/app-defaults/%N The first path in the list expands to ./Myterm.ad. The second expands to $HOME/app-defaults/Myterm. This is a convenient setting for debugging because it follows the Imake convention of naming the app-defaults file Myterm.ad in the application's source directory, so you can run the application from the directory in which you are working and still have the resources loaded properly. NOTE: when looking for app-default files with XUSERFILESEARCHPATH, for some bizarre reason, neither the type nor file suffix is defined so %T and %S are useless. With R5 and R6, there's another twist. You may specify a customization resource value. For example, you might run the "myterm" application like this: myterm -xrm "*customization: -color" If one of your pathname specifications had the value "/usr/lib/X11/%T/%N%C" then the expanded pathname would be "/usr/lib/X11/app-defaults/Myterm-color" because the %C substitution character takes on the value of the customization resource. The default XFILESEARCHPATH, compiled into Xt, is: /usr/lib/X11/%L/%T/%N%C:\ (R5) /usr/lib/X11/%l/%T/%N%C:\ (R5) /usr/lib/X11/%T/%N%C:\ (R5) /usr/lib/X11/%L/%T/%N:\ /usr/lib/X11/%l/%T/%N:\ /usr/lib/X11/%T/%N (Note: some sites replace /usr/lib/X11 with a ProjectRoot in this batch of default settings.) The default XUSERFILESEARCHPATH, also compiled into Xt, is /%L/%N%C:\ (R5) /%l/%N%C:\ (R5) /%N%C:\ (R5) /%L/%N:\ /%l/%N:\ /%N: is either the value of XAPPLRESDIR or the user's home directory if XAPPLRESDIR is not set. If you set XUSERFILESEARCHPATH to some value other than the default, Xt ignores XAPPLRESDIR altogether. Notice that the quick and dirty way of making your application find your app-defaults file in your current working directory is to set XAPPLRESDIR to ".", a single dot. In R3, all this machinery worked differently; for R3 compatibilty, many people set their XAPPLRESDIR value to "./", a dot followed by a slash. [Thanks to Oliver Jones (oj@world.std.com); 2/93.] ---------------------------------------------------------------------- Subject: 33) How to I have xdm put a picture behind the log-in window? R5/R6 users can specify the "setup" script that xdm runs by changing the entry in the xdm-config file (usually in /usr/lib/X11/xdm) to name a different script; the sample script distributed with the X distribution simply runs xconsole. See the SETUP PROGRAM section of the xdm man page in R6 for precise details. Pre-R5 versions of the xdm client could be spoofed by in changing xdm's xrdb resource in the xdm-config file to run a program to change the background before loading the resources; for example, your /usr/lib/X11/xdm/xdm-config file may add the line DisplayManager.0.authorize: false to permit unrestricted access to the display before log-in (beware!) and also DisplayManager*xrdb: /usr/lib/X11/xdm/new.xrdb where that file does something (for all connections) along the lines of: #!/bin/sh #comes in with arguments: -display :0 -load /usr/lib/X11/xdm/Xresources /usr/bin/X11/xsetroot -display $2 -bitmap /usr/lib/X11/xdm/new.bitmap /usr/bin/X11/xrdb $* Substitute xloadimage or xv for xsetroot, to taste. Note that this is a general hack that can be used to invoke a console window or any other client. [Thanks to Jay Bourland (jayb@cauchy.stanford.edu), 9/91] ---------------------------------------------------------------------- Subject: 34) Why isn't my PATH set when xdm runs my .xsession file? When xdm runs your .xsession it doesn't source your .cshrc or .login files. You can set the path explicitly as you normally could for any SH script; or you can place all environment-setting statements in a separate file and source it from both the .xsession file and your shell configuration file; or, if you set your PATH in your .cshrc file, the normal place, you can make your .xsession have PATH set simply by making it a csh script, i.e. by starting your .xsession file off with "#!/bin/csh". If this doesn't work, also try starting off with: #!/bin/sh # Reset path: PATH=`csh -c 'echo $PATH'` ; export PATH ---------------------------------------------------------------------- Subject: 35) How do I keep my $DISPLAY when I rlogin to another machine? There are several ways to avoid having to do a "setenv DISPLAY ..." whenever you log in to another networked UNIX machine running X. A trivial solution, if your account is cross-mounted on both machines, is to have your .xsession write your DISPLAY variable to a file, and then in your login dot-files to check for the existence of that that file and use its contents as your DISPLAY. [Thanks to joachim.fricker@zh014.ubs.ubs.ch.] One solution is to use the clients/xrsh on the R5 and R6 contrib tapes. It includes xrsh, a script to start an X application on remote machine, and xrlogin, a script to start a local xterm running rlogin to a remote machine. A more recent version is on export in contrib/utilities/xrsh-5.8.shar.gz [21/94]. One solution is to use the xrlogin program from der Mouse (mouse@larry.mcrcim.mcgill.edu). You can ftp caveat-emptor versions from ftp.cim.mcgill.ca (132.206.4.7) in pub/people/mouse/X/xrlogin/. The program packages up $TERM and $DISPLAY into a single string, which is stuffed into $TERM. rlogin then propagates $TERM normally; your .cshrc on the remote machine should contain eval `xrlogind` where xrlogind is a program that checks $TERM and if it is of the special format it recognizes, unpacks it and spits out setenv and unsetenv commands to recreate the environment variables. [11/90] In addition, if all you need to do is start a remote X process on another host, and you find rsh -n /usr/bin/X11/xterm -display $DISPLAY too simple (DISPLAY must have your real hostname), then this version of xrsh can be used to start up remote X processes. The equivalent usage would be xrsh xterm #! /bin/sh # start an X11 process on another host # Date: 8 Dec 88 06:29:34 GMT # From: Chris Torek # rsh $host -n "setenv DISPLAY $DISPLAY; exec $@ &/dev/null" # # An improved version: # rXcmd (suggested by John Robinson, jr@bbn.com) # (generalized for sh,ksh by Keith Boyer, keith@cis.ohio-state.edu) # # but they put the rcmd in ()'s which left zombies again. This # script combines the best of both. case $# in [01]) echo "Usage: $0 host x-cmd [args...]";; *) case $SHELL in *csh*) host="$1"; shift xhost "$host" > /dev/null rsh "$host" -n \ "setenv TERM xterm; setenv DISPLAY `hostname`:0; \ exec $* & /dev/null" & ;; *sh) host="$1"; shift xhost "$host" > /dev/null rsh "$host" -n \ "TERM=xterm export TERM; \ DISPLAY=`hostname`:0 export DISPLAY; \ LD_LIBRARY_PATH=/usr/X11/lib export LD_LIBRARY_PATH; \ PATH=\$PATH:/usr/X11/bin:/usr/bin/X11:/usr/local/bin; \ export PATH; \ exec $* < /dev/null > /dev/null 2>&1" & ;; esac ;; esac You may also want to look at programs/rstart in the R6 distribution; this remote execution protocol is intended to work in concert with session managers. ---------------------------------------------------------------------- Subject: 36) How can I design my own font? One way is to use the "bitmap" client or some other bitmap-editor (e.g. Sun's icon-editor tool, post-processed with pbmplus) to design the individual characters and then to do some large amount of post-processing to concatenate them into the BDF format. See Ollie Jones's article in the November 91 X Journal for more information. The R3 contrib/ area (in fonts/utils/ and in clients/xtroff) contained a number of useful utilities, including some to convert between BDF font format and a simple character format which can be edited with any text editor. An easier way is to use the "xfed" client to modify an existing font; a version is on the R4 or R5 X11R5 contrib tape in contrib/clients/xfed. Xfed was last seen on ftp.Informatik.Uni-Dortmund.DE [129.217.64.63], possibly as file /pub/windows/X/Diverse-X11-Sourcen/xfed.tar.Z. It can produce BDF-format fonts which can be compiled for a variety of X servers. IBM machines appear to have a utility "fontutil". The xfedor client from Group Bull permits creation of bitmaps, cursors, XPM1 pixmaps, and fonts. Binaries for common machines are on avahi.inria.fr in /pub; in addition, the sources (an old Xlib implementation) have been placed [5/91] in ftp.x.org:/contrib. If you are a MetaFont user you can use "mftobdf" from the SeeTeX distribution to convert PK, GF, and PXL fonts to BDF format; the distribution is on ftp.cs.colorado.edu and on ftp.x.org. The GNU package fontutils-0.4.tar.Z on prep.ai.mit.edu includes xbfe, a font editor, and a number of utilities for massaging font formats. The O'Reilly X Resource issue #2 contains an article on using these tools to modify a font. Fonts can be resized with Hiroto Kagotani's bdfresize; a new version is in ftp.cs.titech.ac.jp:/X11/contrib. bdffont in the Andrew User Interface System (versions 5.2.2 and higher) lets you create a font or edit an existing one. ---------------------------------------------------------------------- Subject: 37) Why does adding a font to the server not work (sic)? After you have built the font using your system's font-compiler, installed it in some directory, and run `mkfontdir` or your system's equivalent (e.g. bldfamily for OpenWindows) in that directory, be sure to use `xset +fp $dir` to add that full path-name to the server's font-path, *or* if the directory is already in the path, use `xset fp rehash` so that the new fonts in that directory are actually found; it is this last step that you're probably leaving out. (You can also use `xset q` to make sure that that directory is in the path.) Sometimes your "xset +fp $dir" command fails with a BadValue error: X Error of failed request:BadValue (integer parameter out of range for operation) Major opcode of failed request: 51 (X_SetFontPath) This means the X server cannot find or read your font directory, or that your directory does not look like a font directory to the server. (The mention of an "integer parameter" in the message is spurious.) -- Is the font directory you're specifying readable from the SERVER's file system? Remember, it's the server, not the client, which interprets your font directory. Trouble in this area is especially likely when you issue an xset command with shell metacharacters in it (e.g. "xset +fp ~/myfonts") and the server is an X terminal or managed by xdm. -- Is the directory really a font directory? If you're running the sample X server (or most varieties of vendor servers) look in the directory for the file "fonts.dir". If you can't find that file, run mkfontdir(1). (If you're running OpenWindows, look for the file "Families.list". If you can't find it, run bldfamily(1).) -- If you're in a site where some people run X11Rn servers and others run a proprietary server with nonstandard font formats (OpenWindows, for example), make sure the font directory is right for the server you're using. Hint: if the directory contains .pcf and/or .snf files, it won't work for Open Windows. If the directory contains .ff and/or .fb files, it won't work for X11Rn. [thanks to der Mouse (mouse@larry.mcrcim.mcgill.edu) and to Oliver Jones (oj@pictel.com); 7/92 ] Note: some systems (e.g. X11R4 on AIX) need a trailing '/' in the directory name. ---------------------------------------------------------------------- Subject: 38) How do I convert a ".snf" font back to ".bdf" font? A tool called "snftobdf 1.6" can do this; it is available as: ftp.x.org:contrib/snftobdf-1.6.tar.Z crl.nmsu.edu:pub/misc/snftobdf-1.6.tar.Z ---------------------------------------------------------------------- Subject: 39) What is a general method of getting a font in usable format? der Mouse's getbdf is one solution; it connects to a server and produces a .BDF file for any font the server is willing to let it. It can be used as an anything-to-BDF converter, but requires access to a server that can understand the font file, thus is both more and less powerful than other tools such as snftobdf. getbdf is on 132.206.78.1 in X/getbdf.c or available via mail from mouse@larry.McRCIM.McGill.EDU. [5/91] In addition, the R5/R6 program "fstobdf" can produce bdf for any font that the R5 server has access to. ---------------------------------------------------------------------- Subject: 40) How do I use DECwindows fonts on my non-DECwindows server? The DECwindows fonts typically don't exist on a non-DEC installation, but rewrite rules can be used to alias fonts used by DECwindows applications to standard X fonts of similar characteristics and size. Pick up the file contrib/DECwindows_on_X11R4_font.aliases from ftp.x.org; this file is for a sample R4 server. It can also serve as a starting point for creating a similar aliases file for the Open Windows server or other servers which do not use the X Consortium's font scheme. ---------------------------------------------------------------------- Subject: 41) How do I get a font name from the structure? You can't, although you can build up the font properties to rebuild a description of the font in XLFD format, which should be sufficient. This routine is derived from source provided by John L. Cwikla (cwikla@wri.com). #include #include /* Stolen from mit/fonts/lib/font/bitmap/bitscale.c */ enum scaleType { atom, pixel_size, point_size, resolution, resolution_x, resolution_y, average_width, scaledX, scaledY, unscaled, scaledXoverY, uncomputed, }; typedef struct _fontProp { char *name; Atom atom; enum scaleType type; char found; } fontProp; static fontProp fontNamePropTable[] = { { "FOUNDRY", 0, atom, 0}, { "FAMILY_NAME", 0, atom, 0}, { "WEIGHT_NAME", 0, atom, 0}, { "SLANT", 0, atom, 0}, { "SETWIDTH_NAME", 0, atom, 0}, { "ADD_STYLE_NAME", 0, atom, 0}, { "PIXEL_SIZE", 0, pixel_size, 0}, { "POINT_SIZE", 0, point_size, 0}, { "RESOLUTION_X", 0, resolution_x, 0}, { "RESOLUTION_Y", 0, resolution_y, 0}, { "SPACING", 0, atom, 0}, { "AVERAGE_WIDTH", 0, average_width, 0}, { "CHARSET_REGISTRY", 0, atom, 0}, { "CHARSET_ENCODING", 0, atom, 0}, #if 0 { "FONT", 0, atom, 0}, #endif /* 0 */ }; #define NUMITEMS(arr) ((int) (sizeof(arr) / sizeof(arr[0]))) void regenerateFontName(Display *display, XFontStruct *xfs) { int i; unsigned long retValue; if (xfs) { for(i=0;ia: beginning-of-line() \n\ Ctrle: end-of-line() ^ extra space The newline after that space is ending the translation definition. [Thanks to Timothy J. Horton, 5/91] ---------------------------------------------------------------------- Subject: 45) How can I have a clock show different timezones? One solution is xchron, in Volume 6 of comp.sources.x, which can show the time for timezones other than the local one. sunclock on ftp.x.org displays a world map with sun/dark areas and local and UTC time. The OpenWindows clock has a TimeZone property. Modifications to the Xaw clock widget to support hour and minute offsets were posted by David Herron (david@twg.com). A patch for the clock coming with the Xaw3D widgets introduces resources hourOffset, minuteOffset, gmt; it can be found at ftp.wu-wien.ac.at:pub/src/X11/wafe/xaw3d.Clock.patch. Alternatively, you can probably set the timezone in the shell from which you invoke the xclock or oclock, or use a script similar to this: #!/bin/sh TZ=PST8PDT xclock -name "La-La" 2> /dev/null & TZ=EST5EDT xclock -name "Nyah-Nyah" 2> /dev/null & ---------------------------------------------------------------------- Subject: 46) I have xmh, but it doesn't work. Where can I get MH? The xmh mail-reader requires the Rand MH mail/message handling system, which is not part of the UNIX software distribution for many machines. A list of various ftp, uucp, e-mail and US-mail sites for both xmh and MH is given in the monthly MH FAQ posted to comp.mail.mh; one source is ics.uci.edu. ---------------------------------------------------------------------- Subject: 47) Why am I suddenly unable to connect to my Sun X server? After a seemingly random amount of time after the X server has been started, no other clients are able to connect to it. The default cron cleanup jobs supplied by Sun (for 4.0.3, at least) delete "old" (unreferenced) files from /tmp -- including /tmp/.X11-unix, which contains the socket descriptor used by X. The solution is to add "! -type s" to the find exclusion in the cron job. [10/90] ---------------------------------------------------------------------- Subject: 48) Why don't the R5 PEX demos work on my mono screen? The R5 sample server implementation works only on color screens, sorry. ---------------------------------------------------------------------- Subject: 49) How do I get my Sun Type-[45] keyboard fully supported by Xsun? The R6 Xsun supports Sun Type-[45] keyboards; see the KEYBOARDS section of the Xsun man page. Many users wants the Num Lock key to light the Num Lock LED and have the appropriate effect on the numeric keypad. The R5 Xsun server as distributed by the Consortium doesn't do this but there are two different patches available. The first patch is written by Jonathan Lemon and fixes the Num Lock related problems. It is available from ftp.x.org in the file contrib/Xsun-R5.numlock_patch.Z . The second is written by Martin Forssen and fixes the Num Lock and Compose keys and adds support for the different national keyboard layouts for Type-4 and Type-5 keyboards. This patch is available from ftp.x.org in contrib/sunkbd.930314.tar.Z or via email from maf@dtek.chalmers.se. [thanks to Martin Forssen (maf@dtek.chalmers.se or maf@math.chalmers.se), 8/92] A set of patches by William Bailey (dbgwab@arco.com) was posted to newsgroups 11/92 to provide support for the Type-5 keyboard. (Note that use of xmodmap to map function and arrow keys can make the Type 5 keyboard more useful without needing these patches.) ---------------------------------------------------------------------- Subject: 50) How do I report bugs in X? Generally, report bugs you find to the organization that supplied you with the X Window System. If you received the R6 source distribution directly from the Consortium, please read the file xc/bug-report for instructions. [Look in mit/bug-report for R5, mit/doc/bugs/bug-report in R4.] [Thanks to Stephen Gildea , 5/91; 12/91] ---------------------------------------------------------------------- Subject: 51) Why do I get "Warning: Widget class version mismatch"? This error, which typically goes on to say, "widget 11004 vs. intrinsics 11003" indicates that the header files you included when building your program didn't match the header files that the Xt library you're linking against was built with; check your -I include path and -L link-path to be sure. However, the problem also occurs when linking against a version of the X11R4 Xt library before patch 10; the version number was wrong. Some Sun OW systems, in particular, were shipped with the flawed version of the library, and applications which link against the library typically give the warnings you have seen. ---------------------------------------------------------------------- Subject: 52) Why does my SPARC say "Mapping cg3c: No such device or address"? The R6 sun ddx uses information returned by the device driver to do the right thing, so this problem should go away with R6, but the X Consortium does not have this configuration available to test it. This problem comes up on Sun SPARC Classic machines. There is no X Consortium fix for this problem, but the correction can be made to X11R5 sources by editing the file "src/mit/server/ddx/sun/sunCG3C.c". Find the second buffer definition that looks like this: typedef struct cg3bc { #ifdef sparc u_char mpixel[128*1024]; /* bit-per-pixel memory */ u_char epixel[128*1024]; /* enable plane */ #endif u_char cpixel[CG3B_HEIGHT][CG3B_WIDTH]; /* byte-per-pixel memory */ } CG3BC, CG3BCRec, *CG3BCPtr; and change the instances of "128*1024" to "96*1024". Then recompile the X server. [thanks to Russ Poffenberger (poffen@San-Jose.ate.slb.com)] ---------------------------------------------------------------------- David B. Lewis faq%craft@uunet.uu.net "Just the FAQs, ma'am." -- Joe Friday