4 XCOMM This is just a sample implementation of a slightly less primitive
5 XCOMM interface than xinit. It looks for user .xinitrc and .xserverrc
6 XCOMM files, then system xinitrc and xserverrc files, else lets xinit choose
7 XCOMM its default. The system xinitrc should probably do things like check
8 XCOMM for .Xresources files and merge them in, start up a window manager,
9 XCOMM and pop a clock and several xterms.
11 XCOMM Site administrators are STRONGLY urged to write nicer versions.
14 unset DBUS_SESSION_BUS_ADDRESS
17 #if defined(__SCO__) || defined(__UNIXWARE__) || defined(__APPLE__)
19 XCOMM Check for /usr/bin/X11 and BINDIR in the path, if not add them.
20 XCOMM This allows startx to be placed in a place like /usr/bin or /usr/local/bin
21 XCOMM and people may use X without changing their PATH.
22 XCOMM Note that we put our own bin directory at the front of the path, and
23 XCOMM the standard system path at the back, since if you are using the Xorg
24 XCOMM server there's a pretty good chance you want to bias the Xorg clients
25 XCOMM over the old system's clients.
27 XCOMM First our compiled path
31 *:$bindir | *:$bindir:* | $bindir:*) ;;
32 *) PATH=$bindir:$PATH ;;
35 XCOMM Now the "old" compiled path
37 oldbindir=/usr/X11R6/bin
39 oldbindir=/usr/bin/X11
42 if [ -d "$oldbindir" ] ; then
44 *:$oldbindir | *:$oldbindir:* | $oldbindir:*) ;;
45 *) PATH=$PATH:$oldbindir ;;
49 XCOMM Bourne shell does not automatically export modified environment variables
50 XCOMM so export the new PATH just in case the user changes the shell
54 #if defined(__SCO__) || defined(__UNIXWARE__)
55 XCOMM Set up the XMERGE env var so that dos merge is happy under X
57 if [ -f /usr/lib/merge/xmergeset.sh ]; then
58 . /usr/lib/merge/xmergeset.sh
59 elif [ -f /usr/lib/merge/console.disp ]; then
60 XMERGE=`cat /usr/lib/merge/console.disp`
64 userclientrc=$HOME/.startxrc
65 sysclientrc=LIBDIR/sys.startxrc
66 scouserclientrc=$HOME/.xinitrc
67 scosysclientrc=XINITDIR/xinitrc
69 userclientrc=$HOME/.xinitrc
70 sysclientrc=XINITDIR/xinitrc
73 userserverrc=$HOME/.xserverrc
74 sysserverrc=XINITDIR/xserverrc
85 if [ "x$X11_PREFS_DOMAIN" = x ] ; then
86 export X11_PREFS_DOMAIN=BUNDLE_ID_PREFIX".X11"
89 XCOMM Initialize defaults (this will cut down on "safe" error messages)
90 if ! defaults read $X11_PREFS_DOMAIN cache_fonts > /dev/null 2>&1 ; then
91 defaults write $X11_PREFS_DOMAIN cache_fonts -bool true
94 if ! defaults read $X11_PREFS_DOMAIN no_auth > /dev/null 2>&1 ; then
95 defaults write $X11_PREFS_DOMAIN no_auth -bool false
98 if ! defaults read $X11_PREFS_DOMAIN nolisten_tcp > /dev/null 2>&1 ; then
99 defaults write $X11_PREFS_DOMAIN nolisten_tcp -bool true
102 XCOMM First, start caching fonts
103 if [ x`defaults read $X11_PREFS_DOMAIN cache_fonts` = x1 ] ; then
104 if [ -x $bindir/font_cache ] ; then
106 elif [ -x $bindir/font_cache.sh ] ; then
107 $bindir/font_cache.sh &
108 elif [ -x $bindir/fc-cache ] ; then
113 if [ -x XINITDIR/privileged_startx ] ; then
114 # Don't push this into the background becasue it can cause
115 # a race to create /tmp/.X11-unix
116 XINITDIR/privileged_startx
119 if [ x`defaults read $X11_PREFS_DOMAIN no_auth` = x0 ] ; then
125 if [ x`defaults read $X11_PREFS_DOMAIN nolisten_tcp` = x1 ] ; then
126 defaultserverargs="$defaultserverargs -nolisten tcp"
129 if defaults read $X11_PREFS_DOMAIN dpi > /dev/null 2>&1 ; then
130 defaultserverargs="$defaultserverargs -dpi `defaults read $X11_PREFS_DOMAIN dpi`"
137 XCOMM Automatically determine an unused $DISPLAY
140 [ -e /tmp/.X$d-lock ] || break
146 #if defined(__SCO__) || defined(__UNIXWARE__)
148 XCOMM SCO -t option: do not start an X server
150 -t) if [ -n "$DISPLAY" ]; then
154 echo "DISPLAY environment variable not set"
162 while [ x"$1" != x ]; do
164 XCOMM '' required to prevent cpp from treating "/*" as a C comment.
166 if [ "$whoseargs" = "client" ]; then
167 if [ x"$client" = x ] && [ x"$clientargs" = x ]; then
170 clientargs="$clientargs $1"
173 if [ x"$server" = x ] && [ x"$serverargs" = x ]; then
176 serverargs="$serverargs $1"
184 if [ "$whoseargs" = "client" ]; then
185 clientargs="$clientargs $1"
187 XCOMM display must be the FIRST server argument
188 if [ x"$serverargs" = x ] && @@
189 expr "$1" : ':[0-9][0-9]*$' > /dev/null 2>&1; then
192 serverargs="$serverargs $1"
200 XCOMM process client arguments
201 if [ x"$client" = x ]; then
202 client=$defaultclient
204 XCOMM For compatibility reasons, only use startxrc if there were no client command line arguments
205 if [ x"$clientargs" = x ]; then
206 if [ -f "$userclientrc" ]; then
208 elif [ -f "$sysclientrc" ]; then
210 #if defined(__SCO__) || defined(__UNIXWARE__)
211 elif [ -f "$scouserclientrc" ]; then
212 client=$scouserclientrc
213 elif [ -f "$scosysclientrc" ]; then
214 client=$scosysclientrc
220 XCOMM if no client arguments, use defaults
221 if [ x"$clientargs" = x ]; then
222 clientargs=$defaultclientargs
225 XCOMM process server arguments
226 if [ x"$server" = x ]; then
227 server=$defaultserver
229 XCOMM For compatibility reasons, only use xserverrc if there were no server command line arguments
230 if [ x"$serverargs" = x -a x"$display" = x ]; then
231 if [ -f "$userserverrc" ]; then
233 elif [ -f "$sysserverrc" ]; then
239 XCOMM if no server arguments, use defaults
240 if [ x"$serverargs" = x ]; then
241 serverargs=$defaultserverargs
244 XCOMM if no display, use default
245 if [ x"$display" = x ]; then
246 display=$defaultdisplay
249 if [ x"$enable_xauth" = x1 ] ; then
250 if [ x"$XAUTHORITY" = x ]; then
251 XAUTHORITY=$HOME/.Xauthority
257 XCOMM set up default Xauth info for this machine
260 if [ -z "`hostname --version 2>&1 | grep GNU`" ]; then
261 hostname=`hostname -f`
271 authdisplay=${display:-:0}
272 #if defined(HAS_COOKIE_MAKER) && defined(MK_COOKIE)
275 if [ -r /dev/urandom ]; then
276 mcookie=`dd if=/dev/urandom bs=16 count=1 2>/dev/null | hexdump -e \\"%08x\\"`
278 mcookie=`dd if=/dev/random bs=16 count=1 2>/dev/null | hexdump -e \\"%08x\\"`
281 if test x"$mcookie" = x; then
282 echo "Couldn't create cookie"
287 XCOMM create a file with auth information for the server. ':0' is a dummy.
288 xserverauthfile=$HOME/.serverauth.$$
289 trap "rm -f '$xserverauthfile'" HUP INT QUIT ILL TRAP KILL BUS TERM
290 xauth -q -f "$xserverauthfile" << EOF
291 add :$dummy . $mcookie
293 #if defined(__APPLE__) || defined(__CYGWIN__)
294 xserverauthfilequoted=$(echo ${xserverauthfile} | sed "s/'/'\\\\''/g")
295 serverargs=${serverargs}" -auth '"${xserverauthfilequoted}"'"
297 serverargs=${serverargs}" -auth "${xserverauthfile}
300 XCOMM now add the same credentials to the client authority file
301 XCOMM if '$displayname' already exists do not overwrite it as another
302 XCOMM server man need it. Add them to the '$xserverauthfile' instead.
303 for displayname in $authdisplay $hostname$authdisplay; do
304 authcookie=`XAUTH list "$displayname" @@
305 | sed -n "s/.*$displayname[[:space:]*].*[[:space:]*]//p"` 2>/dev/null;
306 if [ "z${authcookie}" = "z" ] ; then
308 add $displayname . $mcookie
310 removelist="$displayname $removelist"
313 XAUTH -q -f "$xserverauthfile" << EOF
314 add :$dummy . $authcookie
320 #if defined(__SCO__) || defined(__UNIXWARE__)
321 if [ "$REMOTE_SERVER" = "TRUE" ]; then
322 exec SHELL_CMD ${client}
324 XINIT "$client" $clientargs -- "$server" $display $serverargs
328 #if defined(__APPLE__) || defined(__CYGWIN__)
329 eval XINIT \"$client\" $clientargs -- \"$server\" $display $serverargs
331 XINIT "$client" $clientargs -- "$server" $display $serverargs
337 if [ x"$enable_xauth" = x1 ] ; then
338 if [ x"$removelist" != x ]; then
339 XAUTH remove $removelist
341 if [ x"$xserverauthfile" != x ]; then
342 rm -f "$xserverauthfile"
347 * various machines need special cleaning up
350 if command -v deallocvt > /dev/null 2>&1; then