pp@wsinti01.info.win.tue.nl (Peter Peters) (03/06/91)
Here's a summary of the responses that were sent to me on the subject of how to detect which windowing system I'm in. Although I've not yet seen a fool proof system, something can be whipped up from the hints and tools that follow...... Thanks to all people that responded, by sending this message you entered the hall of fame.... :-) ------------------------------------------------------------------------------- ----------------------------------------------------------------------------- From: asegu@mfg.amdahl.com (Ashok Segu) Message-Id: <9103020250.AA07119@mfg.amdahl.com> To: pp@win.tue.nl Subject: How to tell Sunview/X Status: OR Hi Peter, Here's a script that I picked off the frame users group. This script is used to see the windowing environment you are in and then to execute the appropriate frame software version. Hope this helps. -Ashok Segu Systems Design Engineer AMDAHL Corporation Sunnyvale, CA - 94088 asegu@mfg.amdahl.com 8<--------------------- script below ------------------------>8 #!/bin/sh -f # Script to invoke various versions of maker. See definitation of the # usageMessage below for a description of variations. I'm whipping # this up from the slew of different commands that have been created # in a slew of different places. KLM 14-Aug-1990 # Establish tail of script invocation name. Script behaviors are dictated to # a large degree by pseudonym used: # ($IFS is used by shell to determine field seperators. By including the # path component delimiter "/" we can use 'for' to parse the components.) wasIFS=$IFS; IFS="/$IFS" for component in $0 ; do scriptName="$component"; done # Restore IFS to unfinagled state: IFS=$wasIFS ### # Different maker versions' startup scripts: ### XVersion13=/depot/xframe/bin/maker SviewVersion21=/depot/frame/bin/maker ### # Help message for "-help" option or for unimplemented or retired pseudonyms. ### usageMessage=\ "'maker': from X or with '-display' arg, starts X version of maker 1.3, else from Sunview, starts Sunview maker 2.1; 'maker2': from X or Sunview, starts Sunview maker 2.1 if possible; if echo "$1" | grep -s "-help"; then echo "$usageMessage" fi ### # Do check to establish windowing environment where script was invoked. ### if test -n "$DISPLAY" || echo "$*" | grep -se "-display"; then environ=x elif test -n "$WINDOW_PARENT"; then environ=sview elif test "$scriptName" != maker2; then echo "($scriptName: Can't determine windowing environment, trying X...)" environ=x DISPLAY=unix:0.0; export DISPLAY else environ="" fi ### # Use modulo 2 math on PID to select randomly between two license servers: # (Adapted from a nifty csh method of Scott Paisley's) ### if test `echo "($$ / 2) * 2" | bc` = $$; then FRAMEUSERSD_HOST=imp; export FRAMEUSERSD_HOST else FRAMEUSERSD_HOST=dip; export FRAMEUSERSD_HOST fi echo "Using $FRAMEUSERSD_HOST as default license server," ### # Okay, here's the dirty work: ### # Default 'maker' and undocumented 'maker.all' versions: if test "$scriptName" = maker -o "$scriptName" = maker.all; then # Start 1.3 X for x invocation or 2.1 sview for sunview invocation if test "$environ" = x; then echo "Trying X version 1.3 maker," exec $XVersion13 $* elif test "$environ" = sview; then echo "Trying Sunview version 2.1 maker," exec $SviewVersion21 $* else echo "Unimplemented version $version - report to <system administrator>" fi # 'maker2' version: elif test "$scriptName" = maker2; then echo "Trying Sunview version 2.1 maker," # Start sunview 2.1 version if test -z "$WINDOW_PARENT"; then echo "'WINDOW_PARENT' environment variable not defined, so sunview maker" echo "probably can't find where to display and won't start." echo "Trying, anyway..." fi exec $SviewVersion21 $* # unrecognized or retired version - give user options and exit: else echo -n "'$scriptName'" if test "$scriptName" = maker21; then # Retired - tell user and make 'em use different command: echo " maker-startup command is being retired." else echo " is not a properly implemented maker-startup command." fi echo "" echo "Here are the alternatives:" echo "" echo "$usageMessage" echo "" echo "Exiting..." fi Ken Manheimer Nat'l Inst of Standards and Technology klm@cme.nist.gov (301)975-3539 (Formerly Nat'l Bureau of Standards) Factory Automation Systems Division Unix Systems Support Manager ------------------------------------------------------------------------------- From: Steve Jarrett <sbil!steve> Message-Id: <9102270949.AA04857@wet> To: pp@info.win.tue.nl Subject: Detection of X windows. Status: OR Peter, Enclosed are two simple tests we use for X. The first is a real simple shell script to check an X server is running in some form. This works at 11R3, 11R4 and on Openwin. The second test is a fairly simple piece of C to check the existance of an X window manager which comes in handy as a call from a script starting an application that needs a wm. We do not use Sunview much here so I cannot help you on the existance of sunviews except that I guess you could test ps aux|grep sunview as a really crude test without any code. Using something like checking for the root window will not work to well as sunview can co-exist with the XTech X servers and OpenWindows emulates the functionality if you have the WINDOW_PARENT and WMGR_ENV_PLACEHOLDER variables set up. Therefore checking for sunview is more difficult as it can exist as well as X or without it. Cheers, Steve. Steve Jarrett. Mail : steve@wet.sbil.com. SBIL. Phone : 010-44-71-721-2422. London. Fax : 010-44-71-419-0029. *** VIEWS EXPRESSED ARE PERSONNEL AND DO NOT REPRSENT MY EMPLOYER *** # /bin/sh function. Returns true/false on X existance. #----------------------------------------------------------------------------------------- # # boolean check_Xserver( void ) # # # Simple test for X. If you can't set the display then X is not happy. # # This should be genericised to check for an existing display variable # but what the heck it works for what I need. # check_Xserver( ) { if [ ! -x /usr/local/bin/X11/xset ]; then logerr "Failed to invoke $appl for USER $USER. (ERROR: can't execute xset.)" 1 exit_val=7; exit fi /usr/local/bin/X11/xset -d unix:0 q >/dev/null 2>&1 return $? } /* Window manager test. This is a lump of simple C code that appears to work for the all WM's we have checked it against. Simply asks for a Redirection event. Only a single client can have this set. The primary user of this event is a Window manager and therefore if can't get this event I assume that a wm has got the event already. This test is primarily used in scripts for applications requiring a wm. */ /* wmtest.c: Quick test for existance of a window manager */ #include <stdio.h> #include <X11/Xlib.h> int RedirectSelected = 0; /* -------------------------------------------------------------------------------- */ main( argc, argv ) int argc; char **argv; { Display *display; int RedirectErrorHandler( ); if ( (display = XOpenDisplay( NULL )) == NULL ) { exit( 1 ); } XSetErrorHandler( RedirectErrorHandler ); XSelectInput( display, RootWindow ( display, DefaultScreen( display ) ), SubstructureRedirectMask ); XSync( display, 0 ); XCloseDisplay( display ); exit( !RedirectSelected ); } /* -------------------------------------------------------------------------------- */ int RedirectErrorHandler( display, event ) Display *display; XErrorEvent *event; { RedirectSelected = 1; return ( 0 ); } ------------------------------------------------------------------------------- From guy@auspex.com Sun Feb 24 04:18:16 1991 Received: from uunet.UU.NET by svin02.info.win.tue.nl (4.1/1.45) id AA20263; Sun, 24 Feb 91 04:18:07 +0100 Received: from auspex.UUCP by uunet.UU.NET with UUCP (5.61/UUNET-primary-gateway) id AA28875; Sat, 23 Feb 91 22:17:53 -0500 Date: Sat, 23 Feb 91 19:14:28 PST From: guy@auspex.com (Guy Harris) Message-Id: <9102240314.AA13782@auspex.com> To: pp@info.win.tue.nl Subject: Re: Detect if in X Status: OR >Can anyone tell me if there's a way to determine if (on a SUN) I'm > >1 - In Sunview >2 - In X (e.g. open look) > >And are these cases destinguishable ?? I forget whether I'd answered you on this one, but you might try looking to see if the environment variable DISPLAY is set and, if so, assume you're in X. (As you note, anybody can define DISPLAY, but if you're willing to live with the risk that somebody might define DISPLAY even if you're not in X, checking for DISPLAY is probably the simplest approach.) It also has the advantage that, unlike OPENWINHOME or WINDOW_PARENT, it should work in *any* X environment under UNIX, not just OW.... ------------------------------------------------------------------------------- From: ddean@rain.andrew.cmu.edu (Drew Dean) Message-Id: <9102240134.AA01091@rain.andrew.cmu.edu> To: pp@info.win.tue.nl Subject: Re: Detect if in X Newsgroups: comp.sys.sun In-Reply-To: <1713@brchh104.bnr.ca> Organization: Carnegie Mellon University Cc: Status: OR To detect if X is running, why don't you check for the X server's socket ? On MIT X11R4, the Unix domain socket is /tmp/.X11-unix/X0 (for screen 0), and it's listening on TCP port #6000 (decimal) for inbound network connections. To be really thorough, you could probably make sure that those sockets speak the X protocol, but I kinda doubt it's necessary unless you're worried about people spoofing the X server. I'm sorry that I don't have any good ideas for SunView...maybe grep for suntools or sunview in the output of ps ? -- Drew Dean Drew_Dean@rain.andrew.cmu.edu [CMU provides my net connection; they don't necessarily agree with me.] ------------------------------------------------------------------------------- From: edelsohn@nova.npac.syr.edu Message-Id: <9102230407.AA18610@shaman.syr.edu> To: pp@info.win.tue.nl Subject: Re: Detect if in X Newsgroups: comp.sys.sun In-Reply-To: <1713@brchh104.bnr.ca> Organization: Syracuse Center for Computational Science/Dept of Physics Cc: Status: OR I look at the NEWSSERVER environment variable. David -- =============================================================================== David Edelsohn SCCS/Dept of Physics INTERNET: edelsohn@sccs.Syr.EDU 201 Physics Bldg/SU Syracuse, NY 13244-1130 "It's only a dream away ..." -- from Time Bandits ending credits song "... Nature cannot be fooled." -- Richard Feynman ------------------------------------------------------------------------------- From: dick@atherton.com (Dick Berens) Message-Id: <9102230145.AA19214@oak.atherton.com> To: pp@info.win.tue.nl Subject: Re: Detection which windowing system I'm in Status: OR >>In article <1768@svin02.info.win.tue.nl> you write: >>Can anyone shed some light on the following problem : >> >>I have a window labelling mechanism (to change the headers >>in the window title bar) that I want to use when in open windows >>and/or sunview. To be able to do so, I have to know whether I'm in >>a window manager or not. All of this is possible using checks on >>environment variables, but these checks ar not 100%. >>Anyone can define e.g. OPENWINHOME or LD_LIBRARY_PATH to be >>whatever they want, so the existence of these environment variables >>do not ensure you are in open windows. So what are the correct >>methods to determine if I'm >> >>1 - on the bare console. (I'm using `tty` == /dev/console right now) >>2 - in sunview >>3 - in open windows >>4 - remote logged in via 1..3 >> >>And these cases should all be distinguishable.... >> >>Any pointers will be appreciated. >> I did the following in an attempt to determine if X11/News is running versus a more MIT traditional environment. The problem was to use xterm or cmdtool. xterm will be used unless the environment variable OPENWINHOME is defined, and if the vendor string generated by xdpyinfo contains the string 'sun', in which case cmdtool will be used If you have gotten some better ideas (I am sure many more exist) could you let me know ------------------------------------------------------------------------------- From: dupuy@hudson.cs.columbia.edu (Alexander Dupuy) Message-Id: <9102222119.AA26548@hudson.cs.columbia.edu> To: pp@info.win.tue.nl In-Reply-To: pp@info.win.tue.nl's message of 21 Feb 91 20:15:00 GMT Subject: Detect if in X Reply-To: dupuy@cs.columbia.edu Status: OR If the environment variable DISPLAY is set, then you're running under X, else if the environment variable WINDOW_PARENT is set, then you're running under SunView. Since OpenWindows sets both (but prefers X) be sure to check the DISPLAY variable first. Also if you are running under OpenWindows or NeWS, the environment variable NEWSSERVER will be set, if you care to check for that. @alex ------------------------------------------------------------------------------- From: John DiMarco <jdd@db.toronto.edu> To: pp@info.win.tue.nl Subject: Re: Detect if in X Newsgroups: comp.sys.sun References: <1713@brchh104.bnr.ca> Message-Id: <91Feb22.154359est.2075@ois.db.toronto.edu> Date: Fri, 22 Feb 1991 15:43:48 -0500 Status: OR In comp.sys.sun you write: >Can anyone tell me if there's a way to determine if (on a SUN) I'm >1 - In Sunview >2 - In X (e.g. open look) >And are these cases destinguishable ?? Any X application defines the DISPLAY variable. DISPLAY is undefined for SunView. John -- John DiMarco jdd@db.toronto.edu or jdd@db.utoronto.ca University of Toronto, CSRI BITNET: jdd%db.toronto.edu@relay.cs.net (416) 978-8609 UUCP: uunet!utai!db!jdd ------------------------------------------------------------------------------- From: "Brian R. Smith" <brsmith@cs.umn.edu> Message-Id: <9102221905.AA25477@cs.umn.edu> To: pp@info.win.tue.nl Subject: Re: Detect if in X Newsgroups: comp.sys.sun References: <1713@brchh104.bnr.ca> Status: OR In comp.sys.sun you write: >Can anyone tell me if there's a way to determine if (on a SUN) I'm >1 - In Sunview >2 - In X (e.g. open look) >And are these cases destinguishable ?? Well, SunView has solid black title bars on the windows, while Open Look has white title bars and resize corners... (Sorry, but it was my first interpretation.) What are you trying to do? Where are you trying to get this information? Inside your .login? A shell script? A C program? >As you will know starting up open windows using the "openwin" script will >define LD_LIBRARY_PATH and OPENWINHOME. Using these environment variables >would be nice, but anybody can define these environment variables, even >when not in open windows. In fact there are situations that you will have >to define these environment variables yourself ! So that's not a certified >way to make sure you're in open windows. There also are other environment >variables (like WINDOW_PARENT) that indicate you are in open windows OR >sunview, but you can't distinguish which one..... if $DISPLAY is set, you're in either X or OpenWindows if $WINDOW_PARENT is set, you're in either SunView or OpenWindows if $NEWSSERVER is set, you're in either NeWS or OpenWindows Of course, these aren't really *certified* ways to determine what's running - they're mainly just side effects. To be sure, you could write a program that would attempt to open a window, to be sure. Or you could just assume they're accurate. -- Brian brsmith@cs.umn.edu ------------------------------------------------------------------------------- From: ne201ph@prism.gatech.edu (Halvorson,Peter J) Message-Id: <9102221704.AA21263@prism.gatech.edu> To: pp@info.win.tue.nl Subject: Re: Detect if in X Newsgroups: comp.sys.sun In-Reply-To: <1713@brchh104.bnr.ca> Organization: Georgia Institute of Technology Cc: Status: OR In article <1713@brchh104.bnr.ca> you write: >X-Sun-Spots-Digest: Volume 10, Issue 44, message 2 >X-Note: Submissions: sun-spots@rice.edu, Admin: sun-spots-request@rice.edu > >Can anyone tell me if there's a way to determine if (on a SUN) I'm > >1 - In Sunview >2 - In X (e.g. open look) > >And are these cases destinguishable ?? > I'm not sure what restrictions you place on solutions, I solve it in a voluntary method ( it's up to the user to have the right .login). Here is my .login, my .cshrc, and a sample script file. Peter Halvorson -- Nuclear Engineering Program Georgia Institute of Technology, Atlanta Georgia, 30332 uucp: ...!{allegra,amd,hplabs,ut-ngp}!gatech!prism!ne201ph Internet: ne201ph@prism.gatech.edu -- peter@fission.gatech.edu # # .login file # if ($TERM != "sun") then set noglob eval `tset -sQ '?vt100'` unset noglob endif # commands to perform at login if ("`tty`" != "/dev/console") exit setenv WinChoice Openwindows echo ' ' echo -n 'Enter Openwindows, Sunview, or Console? ' setenv WinChoice $< switch ( $WinChoice ) case [Cc]*: exit breaksw case [Ss]*: sunview -background rf/SI_collage_5.rf breaksw case[Oo]*: default: $OPENWINHOME/bin/openwin breaksw endsw clear_colormap echo Will logout in 3 seconds. Hit Control-C to stop logout. sleep 3 logout ------------------%<-cut here--------------------------------- # # .cshrc file # # Call system .cshrc source ~root/cshrc # set up search path set lpath = ( ~ ~/bin /home/pvi/bin /usr/games ~/ftp/x11r4/conq/bin ) if ( $?WinChoice ) then switch ( $WinChoice ) case [Cc]*: case [Ss]*: set path = ( $lpath $path .) breaksw case [Oo]*: default: set path = ( $lpath $OPENWINHOME/bin $OPENWINHOME/bin/xview $path .) alias emacs 'emacs -font 8x16 -w =80x35 \!* &' breaksw endsw endif # skip remaining setup if not an interactive shell if ($?USER == 0 || $?prompt == 0) exit input_from_defaults ------------------%<-cut here--------------------------------- #! /bin/tcsh # # Script to do a remote login to a local cyber mainframe. Uses the appropriate # vt100 emulation program for OpenWindows or Sunview. # switch ( $WinChoice ) case [Oo]*: xterm -font 8x16 -mb -nb 8 -sb +sf +si -e telnet nve1 breaksw case [Ss]*: crttool -Wl "CrtTool connected to NVE1" -WL " nve1" -Wt /usr/lib/fonts/fixedwidthfonts/cour.r.16 telnet nve1 breaksw case [Cc]*: default: telnet nve1 breaksw endsw --------------------------------------------------------------------- From: Sandeep Mehta <sxm@philabs.philips.com> Status: OR >> Can anyone tell me if there's a way to determine if (on a SUN) I'm >> >> 1 - In Sunview >> 2 - In X (e.g. open look) >> >> would be nice, but anybody can define these environment variables, even >> when not in open windows. In fact there are situations that you will have >> to define these environment variables yourself ! So that's not a certified >> way to make sure you're in open windows. There also are other environment >> variables (like WINDOW_PARENT) that indicate you are in open windows OR >> sunview, but you can't distinguish which one..... usually people do get away with testing one or more or a combination of the envariables, but as you point out that it not robust. i think most X application try to "open/connect" to the X server as a first step of initialization. If that request fails you know for sure that there is no X server on the display in question. I think a combination of envariable tests and the failed connect request might suffice. sandeep --------------------------------------------------------------------- From: %<@uunet.UU.NET@win.tue.nl>, ?br@@win.tue.nl (Brian Rosen) Message-Id: <9102221407.AA26149@> To: pp@win.tue.nl Subject: Identifying Windows Status: OR We are very interested in this subject. We are about to try to write such a routine. We need to distinguish between Sunview, Real X11R4 and X-11/NeWS. If you find out anything before we figure it out, please let me know. If we figure it out, I'll let you know. Brian Rosen --------------------------------------------------------------------- From: auspex!guy@uunet.uu.net (Guy Harris) Message-Id: <9102200937.AA24336@auspex.com> To: uunet!info.win.tue.nl!pp@uunet.uu.net Subject: Re: Detection which windowing system I'm in Status: OR > This works fine for me as long as I'm in a windowing system (sunview > or open windows). When sitting at my sun console with no windowing > system started up and having done a rlogin, the labelling mechanism > is enabled when it should be disabled ('tty != /dev/console AND $TERM="sun"). > That's the only flaw of this trick, and that's what I want to change..... I'd require that either DISPLAY (for X11/Open Windows) or WINDOW_PARENT (for SunView) be set, as well as requiring that TERM be "sun" or "sun-cmd". That will keep the labelling mechanism from working on an rlogin from within a window system, but given that "rlogin" doesn't pass much in the way of environment variables over the wire, the remote session doesn't have any way to find out whether you are in an rlogin session, so either you have to have it always happen in an rlogin or never happen in an rlogin, unless you can play some sleazy trick involving hiding the information in the TERM environment variable. The headache there is that the hacked-up version of TERM has to stay in your environment, so that it gets passed over the wire; you'd have to somehow arrange that no program get confused by it.... One thing that *might* work would be to set TERM to "sun-cmd" even inside a "cmdtool", and turn on the labelling mechanism iff TERM is "sun-cmd". That means that the "go from cmdtool mode to shelltool mode" escape sequence will be sent out by programs that run in full-screen mode, and they'll also send the "go back to cmdtool mode from shelltool mode" sequence; a quick test *seems* to indicate that those sequences do no harm in a "shelltool", or at least in a SunView "shelltool", and a quick look at the XView code indicates that it shouldn't do any harm in an XView "shelltool". It also means, though, that your ".cshrc" would have to forcibly set TERM to "sun-cmd" if it's set to "sun" and you're running in a window system, because a newly-created "shelltool" will set it to "sun". --------------------------------------------------------------------- From: guy@auspex.com (Guy Harris) Message-Id: <9102192217.AA09585@auspex.com> To: pp@info.win.tue.nl Subject: Re: Detection which windowing system I'm in Status: OR >I have a window labelling mechanism (to change the headers >in the window title bar) that I want to use when in open windows >and/or sunview. To be able to do so, I have to know whether I'm in >a window manager or not. I assume, then, that the window labelling mechanism does *not* involve using the standard "shelltool" escape sequences to change the window title, because: 1) you don't have to know whether you're rlogged in or not; the escape sequences in question work just fine over an "rlogin". 2) you don't have to know whether you're in SunView or Open Windows, because the SunView and XView versions of "shelltool" and "cmdtool" support the exact same escape sequences. If it *does* involve using the standard escape sequences, I'd just check whether the "TERM" environment variable was set to "sun" or "sun-cmd", and if the escape sequences aren't just ignored on the bare console, check for `tty` != "/dev/console" as well. --------------------------------------------------------------------- From: arends@Metaphor.COM (Dale M. Arends) Subject: Re: Detection which windowing system I'm in I use the following checks. If $TERM is set to "xterm" I can expect to be in Xwindows. If $TERM is set to "sun-cmd" I am in a SunView CommandTool window. If $TERM is set to "sun" and... $?WINDOW_ME is true I am in a SunView ShellTool window... $?WINDOW_ME is false I am not in any windowing system. This works on my SPARCstation 1+ running SunOS 4.1. ----------------------------------------------------------------------------- Dale M. Arends arends@Yosemite.Metaphor.com Metaphor Computer Systems, Inc. ...!{apple|decwrl}!metaphor!yosemite!arends Any opinions expressed herein are my own and not those of my employer. They probably aren't interested and maybe don't agree and therefore ... ----------------------------------------------------------------------------- From: belinfan@cs.utwente.nl (Axel Belinfante) Subject: Re: Detection which windowing system I'm in Some time ago i wrote a couple of small C programs that test if X windows or sunview is running. They simply try to open a window and return the corresponding error status. They are called SUNVIEWrunning (tests whether sunview runs) and X11running (tests whether X11 runs or not). I also included below a shorter version of X11running, Xt11running that uses XtInitialize instead of XOpenDisplay. I put a shar file of those programs below. (Or should i only mention them here and post the programs in comp.sources.x?) With respect to the remote login problem... if you pass over the DISPLAY env var during the remote login, X11running will do its job as expected. SUNVIEWrunning will not work, however: it will try to open a window at the console of the *remote* machine! We fiddle a little bit with the TERM env var to pass over the DISPLAY env var in a rlogin, in a similar way as has been discussed in this group some time ago. I hope this helps. #!/bin/sh # This is a shell archive (shar 3.47) # made 03/01/1991 09:41 UTC by belinfan@utis90 # Source directory /home/tools/belinfan/src/lie/Window # # existing files will NOT be overwritten unless -c is specified # # This shar contains: # length mode name # ------ ---------- ------------------------------------------ # 349 -rw-r----- SUNVIEWrunning.c # 448 -rw-r----- X11running.c # 621 -rw-r----- Xt11running.c # # ============= SUNVIEWrunning.c ============== if test -f 'SUNVIEWrunning.c' -a X"$1" != X"-c"; then echo 'x - skipping SUNVIEWrunning.c (File already exists)' else echo 'x - extracting SUNVIEWrunning.c (Text)' sed 's/^X//' << 'SHAR_EOF' > 'SUNVIEWrunning.c' && /* to compile: cc -o SUNVIEWrunning SUNVIEWrunning.c -lsuntool -lsunwindow -lpixrect */ X #include <suntool/sunview.h> #include <stdio.h> X main() { X Frame frame; X X frame = window_create(NULL, FRAME, 0); X if (! frame) { X printf( "SunView is not running\n" ); X exit( 1 ); X } X else { X printf( "SunView is running\n"); X exit( 0 ); X } } SHAR_EOF chmod 0640 SUNVIEWrunning.c || echo 'restore of SUNVIEWrunning.c failed' Wc_c="`wc -c < 'SUNVIEWrunning.c'`" test 349 -eq "$Wc_c" || echo 'SUNVIEWrunning.c: original size 349, current size' "$Wc_c" fi # ============= X11running.c ============== if test -f 'X11running.c' -a X"$1" != X"-c"; then echo 'x - skipping X11running.c (File already exists)' else echo 'x - extracting X11running.c (Text)' sed 's/^X//' << 'SHAR_EOF' > 'X11running.c' && /* to compile: cc -o X11running -I/Window/X11/include X11running.c -lX11 */ X #include <X11/Xlib.h> #include <stdio.h> X main() { X Display *dpy; X char *displayname; X X displayname = (char *) NULL; X dpy = XOpenDisplay( displayname ); X if (! dpy) { X printf( "X11 is not running\n" ); X exit( 1 ); X } X else { X XCloseDisplay( dpy ); X printf( "X11 is running on display %s\n", XDisplayName( displayname )); X exit( 0 ); X } } SHAR_EOF chmod 0640 X11running.c || echo 'restore of X11running.c failed' Wc_c="`wc -c < 'X11running.c'`" test 448 -eq "$Wc_c" || echo 'X11running.c: original size 448, current size' "$Wc_c" fi # ============= Xt11running.c ============== if test -f 'Xt11running.c' -a X"$1" != X"-c"; then echo 'x - skipping Xt11running.c (File already exists)' else echo 'x - extracting Xt11running.c (Text)' sed 's/^X//' << 'SHAR_EOF' > 'Xt11running.c' && /* to compile: cc -o X11running -I/Window/X11/include X11running.c -lX11 */ X #include <X11/Xlib.h> #include <X11/Intrinsic.h> #include <X11/StringDefs.h> #include <stdio.h> X main(argc, argv) int argc; char *argv[]; { /* X Display *dpy; X char *displayname; X X displayname = (char *) NULL; X dpy = XOpenDisplay( displayname ); X if (! dpy) { X printf( "X11 is not running\n" ); X exit( 1 ); X } X else { X XCloseDisplay( dpy ); X printf( "X11 is running on display %s\n", XDisplayName( displayname )); X exit( 0 ); X } X */ X XtInitialize( "main", "xT11running", 0, 0, &argc, argv ); X exit( 0 ); } SHAR_EOF chmod 0640 Xt11running.c || echo 'restore of Xt11running.c failed' Wc_c="`wc -c < 'Xt11running.c'`" test 621 -eq "$Wc_c" || echo 'Xt11running.c: original size 621, current size' "$Wc_c" fi exit 0 -- ___ "Dirlididi! -- piv" __/ \__________ Axel Belinfante <Axel.Belinfante@cs.utwente.nl> | \___/ | University of Twente tfx. +31 53 333815 |___ __ ___ | Tele-Informatics & Open Systems tel. +31 53 893774 | | | / \ (__ | P.O. Box 217 NL-7500 AE Enschede The Netherlands | |__|__\__/____) | "Als das Kind Kind war, wusste es nicht das es Kind war, |_________________| alles war ihm beseelt, und die Seelen waren eins." ----------------------------------------------------------------------------- ----------------------------------------------------------------------------- -- | Peter Peters | UUCP : pp@win.tue.nl | | Eindhoven University of Technology (TUE) | PHONE : +31-(0)40-474120 | | Dept. of Mathematics and Computer Science | TUE : HG 8.82 / 4120 | | Disclaimer : I said WHAT ??? | VHF : pa0ppe |