home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / x / volume17 / xsleep / part01 < prev    next >
Encoding:
Text File  |  1992-04-07  |  6.6 KB  |  236 lines

  1. Newsgroups: comp.sources.x
  2. Path: uunet!haven.umd.edu!darwin.sura.net!mips!msi!dcmartin
  3. From: jef@netcom.com (Jef Poskanzer)
  4. Subject: v17i052: xsleep - trivial X program that sleeps and exits, Part01/01
  5. Message-ID: <1992Apr8.163326.16302@msi.com>
  6. Originator: dcmartin@fascet
  7. Sender: dcmartin@msi.com (David C. Martin - Moderator)
  8. Nntp-Posting-Host: fascet
  9. Organization: Molecular Simulations, Inc.
  10. Date: Wed, 8 Apr 1992 16:33:26 GMT
  11. Approved: dcmartin@msi.com
  12.  
  13. Submitted-by: jef@netcom.com (Jef Poskanzer)
  14. Posting-number: Volume 17, Issue 52
  15. Archive-name: xsleep/part01
  16.  
  17. There may be some other way to do this, but....
  18.  
  19. Xsleep opens up an X connection, sleeps for the specified number of
  20. seconds, and then closes the connection and exits.
  21.  
  22. Why do something so silly?  Well I'll tell you.  It's because many X
  23. servers reset themselves when they have no connections.  This is a
  24. pain when you're starting up a session, because you do an xset, an
  25. xrdb, an xmodmap, etc., and between each one the server resets itself.
  26. So to prevent this, do an xsleep first, then your initializations,
  27. then start up your real clients.
  28. ---
  29. Jef
  30.  
  31.            Jef Poskanzer  jef@netcom.com  jef@well.sf.ca.us
  32.                             INSPECTED BY #6
  33.  
  34. #! /bin/sh
  35. # This is a shell archive, meaning:
  36. # 1. Remove everything above the #! /bin/sh line.
  37. # 2. Save the resulting text in a file.
  38. # 3. Execute the file with /bin/sh (not csh) to create the files:
  39. #    README
  40. #    Imakefile
  41. #    xsleep.c
  42. #    xsleep.man
  43. # This archive created: Thu Apr  2 20:59:55 1992
  44. # By:    Jef Poskanzer
  45. export PATH; PATH=/bin:$PATH
  46. echo shar: extracting "'README'" '(916 characters)'
  47. if test -f 'README'
  48. then
  49.     echo shar: will not over-write existing file "'README'"
  50. else
  51. sed 's/^X//' << \SHAR_EOF > 'README'
  52. X           xsleep - trivial X program that sleeps and exits
  53. X                         Release of 02apr92
  54. X                        Previous release NONE
  55. X
  56. XXsleep opens up an X connection, sleeps for the specified number of
  57. Xseconds, and then closes the connection and exits.
  58. X
  59. XWhy do something so silly?  Well I'll tell you.  It's because many X
  60. Xservers reset themselves when they have no connections.  This is a
  61. Xpain when you're starting up a session, because you do an xset, an
  62. Xxrdb, an xmodmap, etc., and between each one the server resets itself.
  63. XSo to prevent this, do an xsleep first, then your initializations,
  64. Xthen start up your real clients.
  65. X
  66. XFiles in this distribution:
  67. X    README        this
  68. X    Makefile        guess
  69. X    xsleep.c        source sode
  70. X    xsleep.man        man page
  71. X
  72. XTo install:
  73. X    Unpack the files.
  74. X    xmkmf
  75. X    make depend
  76. X    make
  77. X    make install
  78. X
  79. XComments to:
  80. X    Jef Poskanzer  jef@netcom.com  jef@well.sf.ca.us
  81. SHAR_EOF
  82. if test 916 -ne "`wc -c < 'README'`"
  83. then
  84.     echo shar: error transmitting "'README'" '(should have been 916 characters)'
  85. fi
  86. fi # end of overwriting check
  87. echo shar: extracting "'Imakefile'" '(84 characters)'
  88. if test -f 'Imakefile'
  89. then
  90.     echo shar: will not over-write existing file "'Imakefile'"
  91. else
  92. sed 's/^X//' << \SHAR_EOF > 'Imakefile'
  93. X        DEPLIBS = $(DEPXLIB)
  94. XLOCAL_LIBRARIES = $(XLIB)
  95. X
  96. XSimpleProgramTarget(xsleep)
  97. SHAR_EOF
  98. if test 84 -ne "`wc -c < 'Imakefile'`"
  99. then
  100.     echo shar: error transmitting "'Imakefile'" '(should have been 84 characters)'
  101. fi
  102. fi # end of overwriting check
  103. echo shar: extracting "'xsleep.c'" '(1389 characters)'
  104. if test -f 'xsleep.c'
  105. then
  106.     echo shar: will not over-write existing file "'xsleep.c'"
  107. else
  108. sed 's/^X//' << \SHAR_EOF > 'xsleep.c'
  109. X#include <stdio.h>
  110. X
  111. X#include <X11/Xlib.h>
  112. X
  113. Xvoid
  114. Xmain( argc, argv )
  115. X    int argc;
  116. X    char* argv[];
  117. X    {
  118. X    int argn, seconds;
  119. X    char *display_name;
  120. X    Display *display;
  121. X    char* usage = "usage:  %s [-display display] seconds\n";
  122. X
  123. X    argn = 1;
  124. X    display_name = (char*) 0;
  125. X
  126. X    while ( argn < argc && argv[argn][0] == '-' )
  127. X    {
  128. X    if ( strcmp( argv[argn], "-display" ) == 0 ||
  129. X         strcmp( argv[argn], "-displa" ) == 0 ||
  130. X         strcmp( argv[argn], "-displ" ) == 0 ||
  131. X         strcmp( argv[argn], "-disp" ) == 0 ||
  132. X         strcmp( argv[argn], "-dis" ) == 0 ||
  133. X         strcmp( argv[argn], "-di" ) == 0 ||
  134. X         strcmp( argv[argn], "-d" ) == 0 )
  135. X        {
  136. X        ++argn;
  137. X        if ( argn >= argc )
  138. X        {
  139. X        (void) fprintf( stderr, usage, argv[0] );
  140. X        exit( 1 );
  141. X        }
  142. X        display_name = argv[argn];
  143. X        }
  144. X    }
  145. X
  146. X    if ( argn >= argc )
  147. X    {
  148. X    (void) fprintf( stderr, usage, argv[0] );
  149. X    exit( 1 );
  150. X    }
  151. X    seconds = atoi( argv[argn] );
  152. X    if ( seconds <= 0 )
  153. X    {
  154. X    (void) fprintf( stderr, usage, argv[0] );
  155. X    exit( 1 );
  156. X    }
  157. X    ++argn;
  158. X
  159. X    if ( argn != argc )
  160. X    {
  161. X    (void) fprintf( stderr, usage, argv[0] );
  162. X    exit( 1 );
  163. X    }
  164. X
  165. X    display = XOpenDisplay( display_name );
  166. X    if ( display == (Display*) 0 )
  167. X    {
  168. X        fprintf(
  169. X        stderr, "%s: can't open display \"%s\"\n",
  170. X        argv[0], XDisplayName( display_name ) );
  171. X        exit(1);
  172. X    }
  173. X    
  174. X    sleep( seconds );
  175. X
  176. X    XCloseDisplay( display );
  177. X    exit( 0 );
  178. X    }
  179. SHAR_EOF
  180. if test 1389 -ne "`wc -c < 'xsleep.c'`"
  181. then
  182.     echo shar: error transmitting "'xsleep.c'" '(should have been 1389 characters)'
  183. fi
  184. fi # end of overwriting check
  185. echo shar: extracting "'xsleep.man'" '(1109 characters)'
  186. if test -f 'xsleep.man'
  187. then
  188.     echo shar: will not over-write existing file "'xsleep.man'"
  189. else
  190. sed 's/^X//' << \SHAR_EOF > 'xsleep.man'
  191. X.TH xsleep 1 "2 April 1992"
  192. X.SH NAME
  193. Xxsleep - trivial X program that sleeps and exits
  194. X.SH SYNOPSIS
  195. X.B xsleep
  196. X.RB [ -display
  197. X.IR display ]
  198. X.I seconds
  199. X.SH DESCRIPTION
  200. X.PP
  201. X.I Xsleep
  202. Xopens up an X connection, sleeps for the specified number of seconds,
  203. Xand then closes the connection and exits.
  204. X.PP
  205. XWhy do something so silly?
  206. XWell I'll tell you.
  207. XIt's because many X servers reset themselves when they have no
  208. Xconnections.
  209. XThis is a pain when you're starting up a session, because
  210. Xyou do an xset, an xrdb, an xmodmap, etc., and between each
  211. Xone the server resets itself.
  212. XSo to prevent this, do an
  213. X.I xsleep
  214. Xfirst, then your initializations, then start up your real clients.
  215. X.SH AUTHOR
  216. XCopyright (C) 1992 by Jef Poskanzer.
  217. X.\" Permission to use, copy, modify, and distribute this software and its
  218. X.\" documentation for any purpose and without fee is hereby granted, provided
  219. X.\" that the above copyright notice appear in all copies and that both that
  220. X.\" copyright notice and this permission notice appear in supporting
  221. X.\" documentation.  This software is provided "as is" without express or
  222. X.\" implied warranty.
  223. SHAR_EOF
  224. if test 1109 -ne "`wc -c < 'xsleep.man'`"
  225. then
  226.     echo shar: error transmitting "'xsleep.man'" '(should have been 1109 characters)'
  227. fi
  228. fi # end of overwriting check
  229. #    End of shell archive
  230. exit 0
  231. -- 
  232. --
  233. Molecular Simulations, Inc.            mail: dcmartin@msi.com
  234. 796 N. Pastoria Avenue                uucp: uunet!dcmartin
  235. Sunnyvale, California 94086            at&t: 408/522-9236
  236.