home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 22 gnu / 22-gnu.zip / rxstartx.zip / bin / rxstartx.cmd
OS/2 REXX Batch file  |  2000-09-21  |  3KB  |  90 lines

  1. /* RxStartx 0.9 */
  2. params="-bpp 16" /* X-SERVER Parameters */
  3. wm="twm" /* Window manager */
  4.  
  5. fontserver=''  /* fontserver name */
  6. fontserver.!port=7100 /* fontserver port */
  7.  
  8. /* Path to and name of user .xmodmap. Leave empty for default */
  9. usermodmap='' 
  10.  
  11.  
  12. Call Rxfuncadd "SysLoadFuncs", "RexxUtil", "SysLoadFuncs"
  13. Call SysLoadFuncs
  14.  
  15.  
  16. /* Checking global variables */
  17. env = 'OS2ENVIRONMENT'
  18. x11root = VALUE('X11ROOT',,env)
  19. IF x11root = '' THEN DO
  20.     SAY "The environment variable X11ROOT is not set. XFree86/OS2 won't run without it."
  21.     EXIT
  22. END
  23. xserver = translate(VALUE('XSERVER',,env),'\','/')
  24. IF xserver = ''  THEN DO
  25.     SAY "The environment variable XSERVER is not set. XFree86/OS2 won't run without it."
  26.     EXIT
  27. END
  28. if RxFuncQuery("SockLoadFuncs") then
  29.    do
  30.       rc = RxFuncAdd("SockLoadFuncs","RxSock","SockLoadFuncs")
  31.       rc = SockLoadFuncs()
  32.    end
  33.    
  34. serversock  = SockSocket("AF_INET","SOCK_STREAM",0)
  35. xserver.!family = "AF_INET"
  36. xserver.!addr   = "INADDR_ANY"
  37. xserver.!port=6000
  38. if SockBind(serversock,xserver.!)<>0  then do  
  39.  Say "It seems that another X-Server is currently running" SockPSock_Errno(ERRNO)
  40.  call SockClose serversock
  41.  exit  
  42. end 
  43. call SockClose serversock
  44. /* FontServer processing */
  45. if fontserver <>'' then do
  46.  fontserver.!family = "AF_INET"
  47.  fontserver.!addr   = "INADDR_ANY"
  48.  fontsock  = SockSocket("AF_INET","SOCK_STREAM",0)
  49.  if SockBind(fontsock,fontserver.!)<>0  then do 
  50.   Say "FontServer port is busy"
  51.   call SockClose fontsock
  52.  end 
  53.  else do
  54.    say 'Starting fontserver'
  55.   '@start /N "X FontServer"' fontserver
  56.   call SockClose fontsock
  57.  end
  58. end
  59. '@call '||x11root||'\XFree86\lib\X11\xinit\beforestart.cmd'
  60. say 'Starting xserver ' xserver
  61. '@start /fs /f "X Server" /N' xserver  params 
  62. do 15 /* waiting 15 seconds for server start */
  63.  serversock  = SockSocket("AF_INET","SOCK_STREAM",0)
  64.  rc = SockConnect(serversock,xserver.!)
  65.  if rc<>0 then say "Waiting for xserver" rc errno
  66.  if rc=0 then leave
  67.  call SockClose serversock
  68.  call syssleep(1)
  69. end
  70. if rc<>0 then do
  71.  say SockPSock_Errno(ERRNO) "Can`t start XServer"
  72.  exit
  73. end
  74. call SockClose serversock
  75. call VALUE 'DISPLAY',':0.0','OS2ENVIRONMENT'
  76. Say 'Starting '||wm||' window manager.'
  77. '@start "Window Manager" /min /N' wm
  78. '@call '||x11root||'\XFree86\lib\X11\xinit\afterstart.cmd'
  79. if usermodmap<>'' then do
  80.  'xmodmap '||usermodmap
  81. end
  82. say 'Waiting for xserver shutdown'
  83. serversock  = SockSocket("AF_INET","SOCK_STREAM",0)
  84. do  forever
  85.  if SockBind(serversock,xserver.!)=0  then leave
  86.  call syssleep(5)
  87. end 
  88. '@call '||x11root||'\XFree86\lib\X11\xinit\afterexit.cmd'
  89. say 'complete'
  90. call SockClose serversock