dot-emacs: Put a box around the inactive mode line for symmetry.
[profile] / xinitrc
1 #! /bin/bash
2
3 xx= tt=:; if [ "$XINIT_TEST" != "" ]; then xx=: tt=echo; set -x; fi
4 $xx xrdb -override $HOME/.Xdefaults
5 : ${VNCSESSION=false}
6 export __mdw_sechost="`hostname`"
7
8 # --- Do some fiddling ---
9
10 cleanup=":"
11 xset b 10 2000 50
12 xset r rate 500 50
13 xset m 1 1
14 $xx gnome-settings-daemon&
15 $xx mail-notification&
16 $xx $VNCSESSION || $xx gkrellm&
17 if [ "$XINIT_TEST" = "" ] || [ "$XWIDTH" = "" ] || [ "$XHEIGHT" = "" ]; then
18 eval `xscsize -bx`
19 fi
20
21 # --- Crank up ESD ---
22
23 if ! $xx [ -r /tmp/.esd/socket ]; then
24 esd -nobeeps -as 10&
25 cleanup="$cleanup; kill $!"
26 fi
27
28 # --- Start a nice window manager ---
29
30 $xx enlightenment $EOPTS&
31
32 # --- Crank up a screenlock program ---
33
34 if ! $xx $VNCSESSION; then
35 xscreensaver-command -exit
36 xscreensaver -no-splash&
37 fi
38 $xx gnome-panel&
39
40 # --- Emacs window measurements ---
41 #
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
45
46 pick_program () {
47 for i in "$@"; do
48 if type -t >/dev/null "$i"; then echo "$i"; return; fi
49 done
50 echo false
51 }
52
53 : ${emacs=$(pick_program emacs22 emacs21)}
54 $tt Using editor $emacs.
55 case "$emacs" in
56 emacs21)
57 e_colwd=492 e_hextra=34
58 e_colchars=82 e_cextra=-2
59 e_lineht=13 e_vextra=52
60 ;;
61 emacs22)
62 e_colwd=492 e_hextra=8
63 e_colchars=82 e_cextra=-6
64 e_lineht=13 e_vextra=46
65 ;;
66 esac
67
68 # --- Xterm window measurements ---
69 #
70 # Window width is 503 (fixed).
71 # Vertical line pixel height = 13; misc overhead = 23
72
73 : ${term=$(pick_program pterm Eterm xterm)}
74 $tt Using terminal $tt
75 case "$term" in
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;;
79 esac
80
81 # --- GNOME stuff measurements ---
82 #
83 # GNOME panel width = 113
84
85 declare -i xbound="XWIDTH - 113"
86
87 # --- Choose a width for Emacs ---
88 #
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
94 # subtracted.
95
96 declare -i ecols="(xbound - t_wd - e_hextra)/e_colwd"
97 if (( ecols < 2 && xbound > e_colwd * 2 + e_hextra )); then
98 ecols=2
99 elif (( ecols < 1 )); then
100 ecols=1
101 fi
102
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&
105
106 # --- Now place some xterms ---
107 #
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
114 # xterms.
115
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"
118 while true; do
119 if ((x + t_wd > xbound)); then
120 if ((n >= 3)); then break; fi
121 x="pgx + XWIDTH" pgx="pgx + XWIDTH" xbound="xbound + XWIDTH"
122 fi
123 y=0 ht=XHEIGHT
124 while ((ht - hstd >= hmin)); do
125 $term $geom 80x35+$x+$y&
126 y="y + hstd" ht="ht - hstd" n="n + 1"
127 done
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&
134 n="n + 1"
135 fi
136 x="x + t_wd"
137 done
138
139 # --- Wait for the world to end ---
140
141 $xx xwait XWAIT_DIE:XWAIT_DIE_NOW
142 $xx eval "$cleanup"