3 xx= tt=:; if [ "$XINIT_TEST" != "" ]; then xx=: tt=echo; set -x; fi
4 $xx xrdb -override $HOME/.Xdefaults
6 export __mdw_sechost="`hostname`"
8 # --- Do some fiddling ---
14 $xx gnome-settings-daemon&
15 $xx mail-notification&
16 $xx $VNCSESSION || $xx gkrellm&
17 if [ "$XINIT_TEST" = "" ] || [ "$XWIDTH" = "" ] || [ "$XHEIGHT" = "" ]; then
21 # --- Crank up ESD ---
23 if ! $xx [ -r /tmp/.esd/socket ]; then
25 cleanup="$cleanup; kill $!"
28 # --- Start a nice window manager ---
30 $xx enlightenment $EOPTS&
32 # --- Crank up a screenlock program ---
34 if ! $xx $VNCSESSION; then
35 xscreensaver-command -exit
36 xscreensaver -no-splash&
40 # --- Emacs window measurements ---
42 # Horizontal column pixel width = 492; window manager overhead = 34
43 # Column character width = 82; Emacs magic overhead = -2
44 # Vertical line pixel height = 13; misc overhead = 52
48 if type -t >/dev/null "$i"; then echo "$i"; return; fi
53 : ${emacs=$(pick_program emacs22 emacs21)}
54 $tt Using editor $emacs.
57 e_colwd=492 e_hextra=34
58 e_colchars=82 e_cextra=-2
59 e_lineht=13 e_vextra=52
62 e_colwd=492 e_hextra=8
63 e_colchars=82 e_cextra=-6
64 e_lineht=13 e_vextra=46
68 # --- Xterm window measurements ---
70 # Window width is 503 (fixed).
71 # Vertical line pixel height = 13; misc overhead = 23
73 : ${term=$(pick_program pterm Eterm xterm)}
74 $tt Using terminal $tt
76 pterm) t_wd=503 t_lineht=13 t_vextra=23 geom=-geometry;;
77 Eterm) t_wd=504 t_lineht=13 t_vextra=23 geom=-g;;
78 xterm) t_wd=507 t_lineht=13 t_vextra=27 geom=-geometry;;
81 # --- GNOME stuff measurements ---
83 # GNOME panel width = 113
85 declare -i xbound="XWIDTH - 113"
87 # --- Choose a width for Emacs ---
89 # We'd like it to be as wide as possible, allowing for a column of xterms
90 # down the right hand side. However, I'd prefer a double-width Emacs to a
91 # single-width Emacs and xterms. If it's not going to work at all, a single
92 # Emacs column will have to do. Also, there's a strange thing with Emacs21
93 # and the toolbar, so we add on some rows which are later mysteriously
96 declare -i ecols="(xbound - t_wd - e_hextra)/e_colwd"
97 if (( ecols < 2 && xbound > e_colwd * 2 + e_hextra )); then
99 elif (( ecols < 1 )); then
103 declare -i x="ecols * e_colwd + e_hextra"
104 noip $emacs -geometry $((ecols * e_colchars + e_cextra))x$(((XHEIGHT - e_vextra)/e_lineht))+0+0&
106 # --- Now place some xterms ---
108 # A few smaller xterms are in general better than one great big one. 35
109 # lines is a good height for most terminals. 25 lines is a minimum. The
110 # strategy for doling out xterms into a column is to make as many 35-liners
111 # as we can, until the remaining space would be too small for a 25-liner. If
112 # we can get two 25s out of that then we do (largest first); otherwise just
113 # make one big one. We stop at the end of a page, once we've made three
116 declare -i n=0 pgx=0 l h y ht
117 declare -i hstd="35 * t_lineht + t_vextra" hmin="25 * t_lineht + t_vextra"
119 if ((x + t_wd > xbound)); then
120 if ((n >= 3)); then break; fi
121 x="pgx + XWIDTH" pgx="pgx + XWIDTH" xbound="xbound + XWIDTH"
124 while ((ht - hstd >= hmin)); do
125 $term $geom 80x35+$x+$y&
126 y="y + hstd" ht="ht - hstd" n="n + 1"
128 if ((ht >= 2 * hmin)); then h="ht - hmin"; else h=ht; fi
129 l="(h - t_vextra)/t_lineht" h="l * t_lineht + t_vextra"
130 $term $geom 80x$l+$x+$y&
131 y="y + h" ht="ht - h" n="n + 1"
132 if ((ht >= hmin)); then
133 $term $geom 80x25+$x+$y&
139 # --- Wait for the world to end ---
141 $xx xwait XWAIT_DIE:XWAIT_DIE_NOW