------------------------------------------------------------------------------- Why use XResourses X Resources allow you to modify programs and change defaults for X Window applictaions. For example, application Fonts can be set with the following resources, in the appropraite X resource file. ! ! Almost all Xtoolkit application fonts are set with ! XtDefaultFont: 7x14bold ! ! XTerm default font settings ! XTerm*font: 7x14 XTerm*boldFont: 7x14bold For more on font setting see bottom of this file about using CPP macros within your ".Xresource" file. For resources and other hints on other specific X Window Programs, see "hints.Applications" in this directory. Some applications can only be modified via X resources. For example the Motif Window Manager, "MWm" only can be modified with resources. General Motif Window Manager icon resources From my .Xdefaults: Mwm*host1*iconImageBackground: blue Mwm*host1*iconImageForeground: white Mwm*host1*iconImage: Term Mwm*host2*iconImageBackground: red Mwm*host2*iconImageForeground: yellow Mwm*host2*iconImage: terminal Startup for the xterms "host1" f.exec "exec xrsh host1 xterm -ls -name xterm-host1" "host2" f.exec "exec xrsh host2 xterm -ls -name xterm-host2" --- Georg Wittig It also allows you to subvert general simple programs for other uses. For example, If I want a Xprogram which will popup on the screen and wait for the user to press it, I can subvert the XLogo program to do this.... xlogo -g 32x32-5-5 -fg gold -bg firebrick \ -xrm '*baseTranslations: #override : quit()' This will popup a small Gold X on a red background, and exit when the user presses with the mouse button anywhere within the program. Sort of a emergency XLogout button. (See also my XLogout Script) ------------------------------------------------------------------------------- Application Resource Sources (order of setting) Application resources are read by applications from the following locations in order. Note these may vary slightly according to toolkit and machine implimentation. The 7 locations are in order. * Fall Back Resources ( programmed in application ) XtAppInitialize() has an argument accepting a fallback resources string to set initial defaults. These are defaults which must be set for the application to work, if no other defaults are found later. Some programs program in the whole ".ad" file here (Yuck). * Library Resource Files ( 1 file only ) Typically from the directory "/usr/lib/X11/app-defaults/{Class}" Controlled with env var: XFILESEARCHPATH or a internal default serch path (see below and manuals) * User Resource Files ( 1 file only ) Controlled with env vars: XUSERFILESEARCHPATH, XAPPLRESDIR As these vars are normally undefined, this defaults to the {Class} (Application class) file in the users home directory. I myself default XAPPLRESDIR="$HOME/.xapp-defaults" and put my personal specific application default changes in "{Class}" files in that directory. * X Resource Database ( loaded into the server ) See the command xrdb. This has the advantage of being present to all machines using the server. Central. Typically from ".XResources" but could be from anywhere. * X Resource Default Files ( DON'T USE: Use the rdb method instead ) from the file: $HOME/.Xdefaults AND then from file in Env Var $XENVIRONMENT otherwise from file $HOME/.Xdefaults-hostname * Command line option Resources set via the command line or through the standard Xt command line option "-xrm". Most Xt applications also convert specific application option flags (for example "-quite") into their own internal resource settings. * Hardcoded Resources Programmed into application directly, without user control. Such resources usally can not be externally modified (and then usally only after a program has started) and can be a nusence. For example many applications hardcord a icon resource (EG: Netscape). instead of only substituting an icon if the user did not specified one with a resource. Thanks be that the icon specification is only a `hint' to the window manager and the window manager can override the hardcording. The order is that of loading, so resources lower down on this list will override those higher on the list accourding to the precidence rules of XResources. ------------------------------------------------------------------------------- Application Resources (Local and personal resources) setenv XFILESEARCHPATH \ "./%N%C.ad:./%N.ad:/usr/lib/X11/%T/%N%C:/usr/lib/X11/%T/%N" This will force applications to use any app-resource file that it finds IN THE CURRENT DIRECTORY before the library defaults. Note that it also assumes that any resource files in the current directory will have the usual ".ad" suffix appended to the filename. Also not that you can't use the #include directive in the -color defaults as the file included must have a ".ad" on the end. After loading ONE resource from the above path, those resources can them be modified by a second application resource file (or the first if no file was found in the XFILESEARCHPATH) located in the directory declared with something like. setenv XAPPLRESDIR $HOME/.xapp-defaults For more information, See "Xt Resource environment variables" below. ------------------------------------------------------------------------------- Xt Resource environment variables The variables are :- XFILESEARCHPATH, XUSERFILESEARCHPATH, XAPPLRESDIR. Xt loads at most one app-defaults file from the path defined in XFILESEARCHPATH and another from the path defined in XUSERFILESEARCHPATH. For Example: The value of this environment variable is a colon-separated list of pathnames. The pathnames contain replacement characters as follows: %T the literal string "app-defaults" %N application class name %C customization resource (R5 only EG: -color) %S Suffix. None for app-defaults %L language, locale, and codeset (e.g. "ja_JP.EUC") env LANG %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 Example: setenv XFILESEARCHPATH ./%N%C.ad:./%N.ad:$HOME/.x%T/%N%C:$HOME/.x%T/%N 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 The defautl XUSERFILESEARCHPATH, compiled into Xt, is: /%L/%N%C:\ (R5) /%l/%N%C:\ (R5) /%N%C:\ (R5) /%L/%N:\ /%l/%N:\ /%N: where is either XAPPLRESDIR or the users HOME if not defined The resource search order is 1) XFILESEARCHPATH (library application defaults) 2) XUSERFILESEARCHPATH (users application defaults) 3) RESOURCE_MANAGER (server application defaults -- xrdb) 4) SCREEN_RESOURCES (specific screen stuff -- not used normally) 5) $HOME/.Xdefaults 6) $XENVIRONMENT (default value: $HOME/.Xdefaults- ) 7) COMMAND LINE OPTIONS ( -xrm "..." resource values ) 8) INTERNAL BUILTINS ( resources set within the program ) NOTES: XView applications do not look in XAPPLRESDIR (#2) the "-name" option can specify alternate resource file names Appres can be use to find what resources are available to Xt programs ------------------------------------------------------------------------------- Xrdb and using string defines To allow you to use the xrdb string LABELS defines in a resource file is it necessary to define the strings as non zero integers. Cpp will then be able to compare the integers even though it can't compare strings. Johnny Tolliver EG: ! WARNING this example assumes SERVERHOST is not a full DNS hostname ! Adjust accordingally #define dragon 1 ! any number other than 0 would work here #define lyrch 2 ! any different number here #if SERVERHOST == dragon Mwm*configFile: .mwmrc-dragon #elif SERVERHOST == lyrch Mwm*configFile: .mwmrc-lyrch #endif #undef dragon ! don't forget or other problems may occur #undef lyrch NOTES: * This will ONLY work in resource files loaded with xrdb. * The strings defined should not actually appear in the if-endif code or that string will also be converted to a number. * The SERVERHOST (used above) must be the a short hostname, it does not with with FQDN (containing "."characters). If this is a problem set your own define when reading the resources. X11R6 xrdb has had a few more xrdb defines set, in which both the client name and the server name are given with the dots replaced with underscores. EG: it defines the following cpp defines. SRVR_mandarin_dstc_gu_edu_au CLNT_dragon As such the network name problem above is solved with the following xrdb file settings. #if defined(SVRV_dragon) || defined(SVRV_dragon_cit_gu_edu_au) Mwm*configFile: .mwmrc-dragon #elif defined(SVRV_mandarin) || defined(SVRV_mandarin_dstc_gu_edu_au) Mwm*configFile: .mwmrc-mandarin #endif Anthony Thyssen ------------------------------------------------------------------------------- Fedora/Redhat XRdb problem... xrdb is adding space on variable substiutions... https://bugzilla.redhat.com/show_bug.cgi?id=640366 Trivial Test... echo 'someXResource: HOME/file' | xrdb -merge -DHOME=/my/home/dir xrdb -q | grep someXResource Results someXResource: /my/home/dir /file Instead of someXResource: /my/home/dir/file Problem is caused by "xrdb" using "mccp" which does this. That is the Fedora package is built with... --with-cpp=mcpp Workaround is to tell "xrdb" NOT to use "mccp" rdb -cpp /bin/cpp .... If "xrdb" was to use "mccp" it shoudl also include either "-@kr" or "-@old" option. Either way then the issue would also be solved. ------------------------------------------------------------------------------- Xt shell resources XtNtitle String title of the shell window XtNiconName String icon name for program XtNallowShellResize Boolean let the child resize the shell window XtN{min,max}{Height,Width} set dimension limits,increments XtN{min,max}Aspect{X,Y} XtN{height,width}Inc XtNbase{Height,Width} ------------------------------------------------------------------------------- Double Clicking -- It does not work as expected Example 1 (2): double()\n\ : single()\n\ This performs a single click then the double click! Example 2 (2): double()\n\ : single()\n\ This seems to work but now performs the double followed by a single! due to a leftover Btn1Up on the queue. Example 3 (2), : double()\n\ : single()\n\ Fixes that but the single is never ever performed ever! Programmed fix -- using the original translation on single click -- add timeout action for single event on double click -- remove single click timeout -- do the double action time for timeout is XtGetMultiClickTime(XtDisplay(w)) Basically to allow double click events the application (or event manager) must have double click events (an timeout) programmed into it. ------------------------------------------------------------------------------- General problems with setting a application main window icon 1/ If the application sets its icon internally and provides no resource methods to change the icon, only the window manager can force the application to use a different icon. (IE: "forceicons" switch in your "twm" configuration file) 2/ If the application does not set an icon and is Xt based then you can set the `iconPixmap' resource to set it. But Xlib applications must provide its own resource provision to allow the user to specify an icon for the application. 3/ Some applications use a changing icon to indicate status EG: XMail, ZMail, FtpTool, Xarchie. The only good way of setting the icon in this situation is my the resource settings that that application should provide. NOTE: FtpTool uses three icons + its standard icon for some animation and does not provide any hooks for changing the icons it uses. 4/ Really bad applications do not provide a class or instance name for itself, and as such resources are basically usless. Some of these even use a variable title bar making the "twm" application select method to fail as well. The best solution I found is to :- 1/ Use the window manager to set the icon for most of the general applications to override any internal icon that application may have. 2/ Use resources to set the icon for status indicating applications such as xmail. 3/ Xterms are a special case, I use resources to set the icons for these, to correspond to the host name it is logged into (the xrsh and xrlogin programs automatically names xterm's with "xterm-"), or for the special use of the xterm, This is useful for special application terminals, such as: news reading, mail handling, special editors, "vifm", "mutt", etc., etc., See below for an example. 4/ The only other special case I deal with are xterms that are running on a machine that does not have a copy of the icon set I am using. In this special case I re-enforce the icon selection of the xterm with a local icon set via the window manager (as in 1). --- Anthony Thyssen Terminal Application Icons... For example "mutt" running in an xterm. For this start the xterm setting the terminal resource "name". #! /bin/sh # ~/bin/xmutt xterm -name mutt -e mutt "$@" Then define the icon with resources mutt*title: mutt mutt*font: xft:terminus:pixelsize=16 mutt*iconFile: /usr/share/icons/gnome/16x16/emblems/emblem-mail.png mutt*scrollBar: false You can also define them using "-xrm" on the command line xterm -name abc \ -xrm "abc*font: 6x13" \ -xrm "abc*title: mutt" \ -xrm "abc*scrollBar: false" \ -e sleep 3 ------------------------------------------------------------------------------- Translation interface for OpenLook Cut and Paste *Text.translations: #override \n\ L6: extend-start() extend-end(PRIMARY, CLIPBOARD, CUT_BUFFER0 )\n\ L8: insert-selection(CLIPBOARD) \n\ L10: extend-start() extend-end(PRIMARY, CLIPBOARD, CUT_BUFFER0 )\n\ L10: kill-selection() XTerm*VT100.Translations: #override \n\ L6: start-extend() select-end(PRIMARY, CLIPBOARD, CUT_BUFFER0)\n\ L8: insert-selection(CLIPBOARD) \n\ L10: start-extend() select-end(PRIMARY, CLIPBOARD, CUT_BUFFER0) NOTE: in openlook all cut and pasting is performed by Left-Function Keys Which under X11R5 is defined as F11 to F20. Under X11R6 these are defined by the keys functional name. EG: SunProps ------------------------------------------------------------------------------- Using CPP in XResource file ! ------------- Resources for larger fonts ----------- ! ! Personal X resources file ".Xresources" ! #define FONT 8x13 #define BFONT 8x13bold ! ! Other font sizes for the above ! 6x13 7x13 7x14 8x13 9x15 ! 6x13bold 7x13bold 7x14bold 8x13bold 9x15bold ! Others exist but not with simple font alias names like these given. ! (See "hints.Fonts") ! ! ! Unicode fonts... ! #define FONT "-misc-fixed-medium-r-*-*-15-*-75-75-c-90-iso10646-1" ! #define BFONT "-misc-fixed-bold-r-*-*-15-*-75-75-c-90-iso10646-1" ! ! The pixel height -----^ ! ! ! ! Other fonts... ! ! "-xos4-terminus-... ! ! "-*-lucidatypewriter-... ! ! "-urw-nimbus mono l-... ! ! ---------------------------------------- ! Almost all Old Xtoolkit widgets use this default font... ! XtDefaultFont: BFONT ! These resource override the default settings of specific applications ! XTerm*font: FONT XTerm*boldFont: BFONT XMail*Font: FONT XMail*buttonFont: BFONT XMail*helpFont: BFONT Axinfo*Hyper.normalFont: FONT Axinfo*Hyper.hightlightFont: BFONT Ups.SrcFont: FONT Ups.MenuFont: FONT Ups.EditFont: BFONT -------------------------------------------------------------------------------