[comp.windows.x] Captain Defaults vs. the Resource Mangler from Outer Space

sherouse@godot.radonc.unc.edu (George W. Sherouse) (11/14/88)

It seemed simple enough.  One machine, one set of defaults.  What a
concept!

I like to have one set of default resources *per machine*.  Godot is
green on black, Molasses is yellow on black, Zarquon is cyan on black,
etc.  Not just login xterms, either.  Everything.  This helps keep my
simple mind on the straight and narrow.  For instance, I don't reboot
the wrong machine quite as often as I used to.  (Think I'll try out
this new kernel... /etc/shutdown -r now...  [Shrieks from other room]
Ack!  NO, NO, I MEANT THAT ONE. [grumbles] *@#! windows...)

Since the X10 days I have set up .Xdefaults with something like

.foreground:	some_color
.border:	some_complementary_color
.background:	black

where some*_color is different on each machine.  I can then run a
startup script like the following on ANY machine and get the same
happy results.  Any new clients I start will show up with the proper
color coding since they look up resources from .Xdefaults on the
machines where they are executing and I will stay only acceptably
confused.

--- Begin startup script
twm &
xset c 100 &
xsetroot -bitmap /usr/include/X11/bitmaps/xlogo32 -bg "dark slate grey" -fg "dim grey" &
xclock -digital -geometry 215x35-0+0 -display `hostname`:0 &
xcalc -rpn -geometry 246x161-0-0 -display `hostname`:0 &
rsh godot "/usr/bin/X11/xload -geometry 180x60+0+0 -display `hostname`:0" &
rsh mo "/usr/bin/X11/xload -geometry 180x60+180+0 -display `hostname`:0" &
rsh zarquon "/usr/bin/X11/xload -geometry 180x60+360+0 -display `hostname`:0" &
rsh bartleby "/usr/bin/xload -update 1 -geometry 180x60+540+0 -display `hostname`:0" &
rsh godot "/usr/bin/X11/xterm -i -ls -n godot -geometry 80x60+0-0 \#+100+0 -display `hostname`:0" &
rsh mo "/usr/bin/X11/xterm  -i -ls -n molasses -geometry 80x60+130-0 \#+280+0 -display `hostname`:0" &
rsh zarquon "/usr/bin/X11/xterm  -i -ls -n zarquon -geometry 80x60+260-0 \#+460+0 -display `hostname`:0" &
rsh bartleby "/usr/bin/xterm  -ic -ls -n bartleby -geometry 80x60-0-0 \#+640+0 -display `hostname`:0" &
rsh godot "/usr/bin/X11/xbiff -geometry +720+0 -display `hostname`:0" &
rsh godot "/usr/bin/X11/xterm -i -ls -n godot -geometry 80x40+170+140 \#+720+50 -display `hostname`:0" &
--- End startup script

Enter xdm, the evil hunchman of the Resource Mangler.  .Xdefaults is
passe, .Xresources is hip.  However, the ugly truth which I have
managed to extract by convolving some experimental results with Jim
Fulton's tutorial is that if you use the resource manager at all (for
instance to customize xdm) then your .Xdefaults files ON ALL MACHINES
are forever ignored.  Further, there appears to be no way to specify
to the resource manager that all clients on a given (remote) machine
have the same resource defaults.  The resource names are at least one
hierarchical step short; rather than program.name.subname.etc it seems
to me they need to be originating_host*program.name.subname.etc.

Or have I missed something?

Anxiously awaiting words of enlightenment...
- George

kit@athena.mit.edu (Chris D. Peterson) (11/14/88)

This can actually be done quite easily, you just have to know how :-).
Resources are retrieved in the following manner (I think I got them
all but I am going from memory).

1) Look in /usr/lib/X11/app-defaults/<program-name> or where the
   environment variable $XAPPLRESDIR/<program-name> points to.
   (Toolkit application only?)

2) a - If no resources are on the server then use .Xdefaults
   b - If resources exist on the server then get them off the server.

3) Look in the users $XENVIROMENT file. (This is were you put
   per machine resources.) 

As each of these steps in taken, and the resources are smashed
if they conflict, so that the order of importance is 3,2,1.

Now about the XENVIRONMENT file.  If the environment variable
XENVIRONMENT is not set the file used for you resources is
$HOME/.xdefaults-<host> where <host> is the name of the current
machine.  Thus you can either set up you XENVIRONMENT correctly, or
you can use the ~/.Xdefaults-<host> files.

For further reading read the X11R3 Xlib manual - page 199.


						Cheers,

						Chris D. Peterson     
						Project Athena     
						Systems Development

Net:	kit@athena.mit.edu		
Phone: (617) 253 - 1326			
USMail: MIT - Room E40-342C		
	77 Massachusetts Ave.		
	Cambridge, MA 02139		

kirills@CITIAGO.BITNET (Kirill V. Shcheglov) (11/14/88)

Who are you and why are you sending me mail?
          kirill.

janssen@titan.sw.mcc.com (Bill Janssen) (11/14/88)

Ah, it gets worse.  I have two screens, one `75 dpi' (a normal Sun CG2),
and the other `100 dpi', a hi-res sun monochrome.  When I start an xterm
on the `100 dpi', I want it to use courb18, whereas courr14 does quite
well on the `75 dpi' screen.  Similarly, I want to specify different
colors for the color screen than for the monochrome screen.

Perhaps the values in the resources data base could be interpreted functions
which take a single argument, a plist of environment values, and calculate
a return value from them...

(funcall #'(lambda (ENV)
	     (case (getf ENV :dpi)
	       (100 "courb18")
	       (75  "courr14")
	       (t   "courr14"))
	     )
	 '(:host "foo"
	   :screen 3
	   :monochrome-screen t
	   :dpi 100
	   :class "xterm")
	 )

--
'(:poster "Bill")