------------------------------------------------------------------------------- Failure to open display The dreaded "Error: Can't open display:" error __reason__ __symptom or test__ + DISPLAY env is not set No display name apprears after the error + no connection (physical) unable to ping the display machine (xterm) + no authorization no auth or XAUTORITY points elsewhere This last is often caused by remote logins, su to a different person. If you are on the logged into machine as that person then this could not be the problem as you must have other windows open. + Bad Authorization authority file has a "##fff#f" entry A authority entry like this is used by xdm to override all other entries. X uses that key for all the connections and ignores any other regular host/key specs present. (azhao@cs.arizona.edu) + Staticly Linked Prog Able to run other x program but not this one A couple of Client that we not compiled locally (Asterix, Frame, WP) are statically linked to the original Sun libraries. These programs do NOT understand the name server usage on our systems. SOLUTION: set you display to the xterminals IP instead of its name. EG: oldIFS=$IFS; IFS=:; set -- $DISPLAY; IFS=$oldIFS; Machine=$1; Screen=$2 IPNumber=`/usr/etc/arp $Machine | sed 's/[^(]*(\([^)]*\).*/\1/'` DISPLAY="$IPNumber:$Screen" export DISPLAY echo "DISPLAY=$DISPLAY ($Machine)" This was only a problem on old SunOS machines where the DNS library was not installed by default. + Above -- but still fails Program does its own check on xhost permisson Only one case of this has been seen (Nexpert) the only solution was to add the current machine to the xhost list. To do this with minimal security problems :- 1/ xhost +$host 2/ run client (background) 3/ after client has started RESET the xhost to close security hole. xhost -$host ------------------------------------------------------------------------------- Xsession Logout (How your xsession logs out) Your X window session only exists while the shell process executing your .xsession file is running. When this process dies or exits, the XDM or GDM thinks that you are finished and will logout the display and start a new login window. To stop the session script exiting it will generally run a X window client in the foreground (not the background, by omitting the "&" at the end of the command), as the very last command in X session script. So when when that program dies your X session falls of the end of the script and XDM logs you out. Typlically this X window client is one of the following 1/ The window manager (so exiting your WM is session logout) twm, openbox, gnome-shell 2/ A special client to provide a logout facility xlogout -g -5-5 # provide a logout button with confirm 3/ Some other xwindow client, (quit it causes logout) xterm -g80x5+5+5 -C # wait for user to exit console Often the .xsession process exec's to the above `session hang' program so the shell actually stops reading the .xsession script and becomes the actual hanging client. This saves on a process that the user is running. For example at the end of the script you will see something like... exec xlogout -g -5-5 # anthing following is never executed. ------------------------------------------------------------------------------- XClosedown Program This program kills all Xwindow programs, nicely first with a delete-window event (lightning button) then 2 seconds later a destroy-window event (nuke button). This in general causes a user session to be killed, as one of the X client programs killed should have been the client program that user's session is `hanging' from. NOTE: the xlogout program is a shell script which uses xmessage to create the logout button, which the user presses to logout of his session, it is possible to do weird things. ------------------------------------------------------------------------------- Session close down experiments EOF of script : The XDM resets the display which of course kills off all clients (using destroy window) except subshell programs in xterms xkill -all : Just perform a "destroy window" on all applications xclosedown : kills off all clients (including notify) except subshell programs in xterms, and the xsession script itself. It will try a clean "delete window" signal to applications before attempting a hard "destory window". -- PREFERED METHOD kill -1 0 : all programs run from the script except window manager and xterms including the script. Note the xsession script should depend on some X application, so it will exit when that program exits. ------------------------------------------------------------------------------- Kill a application with a specific name... For example kill the X window application named "xlogout" xwininfo -name xlogout | awk 'NR==2{print$4}' ------------------------------------------------------------------------------- Getting all the display information needed in bourne shell eval `xrdb -symbols | sed -e 's/-D\([^=]*=\)/\1/g' -e 's/-D\([^ ]*\)/\1=/g'` HOST=`hostname` converts all the xrdb symbols into shell variables for use by your program This is much simpler than greping through the xdpyinfo output. output variables SERVERHOST CLIENTHOST VERSION REVISION VENDOR RELEASE WIDTH HEIGHT X_RESOLUTION Y_RESOLUTION PLANES BITS_PER_RGB CLASS NOTE: You must reset `HOST' as this is would in some cases be set to the X servers host and not the local host. Original Idea : --- Stig Ostholm ------------------------------------------------------------------------------- Color Resource Files To make use of the "-color" resource files placed in the application resource directories, you need to add the following to one of your global resource directories. #ifdef COLOR *customization: -color #endif ------------------------------------------------------------------------------- Xterms and other character codes XTerm*Font: -Misc-Fixed-Medium-R-Normal--14-130-75-75-C-70-ISO8859-1 XTerm*VT100.eightBitInput: true XTerm*VT100.eightBitOutput: true then tell the system stty pass8 NOTE: csh and tcsh both attempt to protect the user (tcsh user can use setty) To use do so from a bourne shell script. ------------------------------------------------------------------------------- Xterm auto iconify (to unreadable) on enter and leave resourses NOTE: This should have the window manager auto-raise too XTerm*vt100.translations: #augment \n\ :set-vt-font(d)\n\ :set-vt-font(1) ------------------------------------------------------------------------------- Startx script and Sun consoles The startx script says "Site administrators are STRONGLY urged to write nicer versions," so I did. When we started to have this problem I added the following to the begining of startx: if ( "`tty`" != "/dev/console" ) then echo "Please run startx from the console not from" `tty` echo `whoami` "ran startx from a tty other than console" | root echo "Please run startx from the console not from" `tty` | mail `whoami` sleep 10 exit 1 endif Although this is not foolproof, We haven't had any problems since. -- Daniel J. McCoy ------------------------------------------------------------------------------- FireWall Bypassing | I am on machine A. I connect to machine B, 'cause it's the only way | that I can connect to machine C. All machines involved are running X | Windows and TCP/IP. I want to make something that I run on machine C | display on machine A. How do I go about this? Solution is to have a X message forwarder :- Run xmon on machine B. Then machine C can access machine A via machine B. (A): xhost ip-address-of-machine-C (A): xhost machine-B (A): rlogin machine-B (B): setenv DISPLAY machine-A:0 (B): xmonui -iconic | xmond & # start forwarder (could be xscope) (B): rlogin machine-C (C): setenv DISPLAY machine-B:1 # A pseudo Xtty, created by xmon (C): run-Xapplication ------------------------------------------------------------------------------- About Background Images While background pictures are well and good a few points is worth considering. 1/ A background picture in stored in the memory of the Xterminal you are using. For a picture on a NCD this equates to over a 1/2 megabyte of the xterminals memory of which it only has 4 megs. With an NCD this is ok. However a large screen like a labtam requires about a full meg of memory! And It gets up to 8 times worse when you add color! -- REMEMBER THIS This memory is required for application, bitmaps and other off screen data such as "save unders". Some applications will just die if this memory is not available -- xfig is one of these. 2/ A background picture requires the X server (the drawing daemon) to do a lot of work when windows are created, moved or deleted. A small tile bitmap is handled much more efficently by the X server and requires only a pittance of Xterminal memory. If you can actually see the Server re-drawing the background after you iconise a window, I suggest it is time to switch to a smaller background tile pattern. 3/ For bitmaps the best program to use to set the background is the X window system core program "xsetroot". For Gif, Tiff and Jpeg. two programs are available "xloadimage" and "xv". The recommendation is "xloadimage", and an example for this is in the default Xsession file (both staff and students). The other program "xv" is HUGE due to its hightly interactive nature and as such requires lots or resources better used elsewhere. These programs should also be run with "nice" and backgrounded. The nice will force the program to work only when the computer has a free moment and every now and then while the background means that you don't have to wait for it to appear before you can do work. You can also speed up this processing by using the "xv" program interactivly to save a Black and White Bitmap image at the correct size for your display, so that the xloadimage program doesn't have to do this processing itself. NOTE: xloadimage understands compressed X bitmaps! -------------------------------------------------------------------------------