initial commit
[profile/ivi/xorg-x11-xinit.git] / startx.cmd
1 /* OS/2 REXX */
2 /* $XFree86: xc/programs/xinit/startx.cmd,v 3.3 1996/10/17 15:23:47 dawes Exp $
3  * 
4  * This is just a sample implementation of a slightly less primitive 
5  * interface than xinit.  It looks for user xinitrc.cmd and xservrc.cmd
6  * files, then system xinitrc.cmd and xservrc.cmd files, else lets xinit choose
7  * its default.  The system xinitrc should probably do things like check
8  * for Xresources files and merge them in, startup up a window manager,
9  * and pop a clock and serveral xterms.
10  *
11  * Site administrators are STRONGLY urged to write nicer versions.
12  */
13 '@echo off'
14 ADDRESS CMD
15 env = 'OS2ENVIRONMENT'
16 x11root = VALUE('X11ROOT',,env)
17 IF x11root = '' THEN DO
18         SAY "The environment variable X11ROOT is not set. X/OS2 won't run without it."
19         EXIT
20 END
21
22 home = VALUE('HOME',,env)
23 IF home = '' THEN home = x11root
24 os_shell = VALUE('X11SHELL',,env)
25 IF os_shell = '' THEN os_shell = VALUE('SHELL',,env)
26 IF os_shell = '' THEN os_shell = VALUE('OS2_SHELL',,env)
27 IF os_shell = '' THEN DO
28         SAY "There is no command interpreter in OS2_SHELL ???"
29         EXIT
30 END
31
32 userclientrc = home'\xinitrc.cmd'
33 userserverrc = home'\xservrc.cmd'
34 sysclientrc  = x11root'\usr\X11R6\lib\X11\xinit\xinitrc.cmd'
35 sysserverrc  = x11root'\usr\X11R6\lib\X11\xinit\xservrc.cmd'
36 clientargs   = ''
37 serverargs   = ''
38
39 IF exists(userclientrc) THEN
40         clientargs = userclientrc
41 ELSE 
42 IF exists(sysclientrc) THEN
43         clientargs = sysclientrc
44
45 IF exists(userserverrc) THEN
46         serverargs = userserverrc
47 ELSE 
48 IF exists(sysserverrc) THEN
49         serverargs = sysserverrc
50
51 whoseargs = "client"
52 PARSE ARG all
53
54 DO i=1 TO WORDS(all)
55         cur = WORD(all,i)
56         IF \(FILESPEC('DRIVE',cur) = '') THEN DO
57                 IF whoseargs = "client" THEN
58                         clientargs = cur
59                 ELSE
60                         serverargs = cur
61         END
62         ELSE
63         IF cur = "--" THEN 
64                 whoseargs = "server"
65         ELSE 
66         IF whoseargs = "client" THEN
67                 clientargs = clientargs' 'cur
68         ELSE
69                 serverargs = serverargs' 'cur
70 END
71
72 xinit = x11root'\usr\X11R6\bin\xinit'
73 xinit os_shell' /c 'clientargs' -- 'serverargs
74
75 RETURN
76
77 exists:
78         IF STREAM(arg(1), 'C', 'QUERY EXISTS') = '' THEN
79                 RETURN 0
80         ELSE
81                 RETURN 1