Also overhaul it so that it can pick out sensible Emacs and terminal
programs, and parameterize the placement algorithm so that it can cope.
Finally, add some testing infrastructure so that I don't have to log out
and in again to see if I fixed it properly!
-xrdb -override $HOME/.Xdefaults
+xx= tt=:; if [ "$XINIT_TEST" != "" ]; then xx=: tt=echo; set -x; fi
+$xx xrdb -override $HOME/.Xdefaults
: ${VNCSESSION=false}
export __mdw_sechost="`hostname`"
: ${VNCSESSION=false}
export __mdw_sechost="`hostname`"
xset b 10 2000 50
xset r rate 500 50
xset m 1 1
xset b 10 2000 50
xset r rate 500 50
xset m 1 1
-gnome-settings-daemon&
-mail-notification&
-$VNCSESSION || gkrellm&
-eval `xscsize -bx`
+$xx gnome-settings-daemon&
+$xx mail-notification&
+$xx $VNCSESSION || $xx gkrellm&
+if [ "$XINIT_TEST" = "" ] || [ "$XWIDTH" = "" ] || [ "$XHEIGHT" = "" ]; then
+ eval `xscsize -bx`
+fi
-if ! [ -r /tmp/.esd/socket ]; then
+if ! $xx [ -r /tmp/.esd/socket ]; then
esd -nobeeps -as 10&
cleanup="$cleanup; kill $!"
fi
# --- Start a nice window manager ---
esd -nobeeps -as 10&
cleanup="$cleanup; kill $!"
fi
# --- Start a nice window manager ---
+$xx enlightenment $EOPTS&
# --- Crank up a screenlock program ---
# --- Crank up a screenlock program ---
+if ! $xx $VNCSESSION; then
xscreensaver-command -exit
xscreensaver -no-splash&
fi
xscreensaver-command -exit
xscreensaver -no-splash&
fi
# --- Emacs window measurements ---
#
# --- Emacs window measurements ---
#
# Column character width = 82; Emacs magic overhead = -2
# Vertical line pixel height = 13; misc overhead = 52
# Column character width = 82; Emacs magic overhead = -2
# Vertical line pixel height = 13; misc overhead = 52
+pick_program () {
+ for i in "$@"; do
+ if type -t >/dev/null "$i"; then echo "$i"; return; fi
+ done
+ echo false
+}
+
+: ${emacs=$(pick_program emacs22 emacs21)}
+$tt Using editor $emacs.
+case "$emacs" in
+ emacs21)
+ e_colwd=492 e_hextra=34
+ e_colchars=82 e_cextra=-2
+ e_lineht=13 e_vextra=52
+ ;;
+ emacs22)
+ e_colwd=492 e_hextra=8
+ e_colchars=82 e_cextra=-6
+ e_lineht=13 e_vextra=46
+ ;;
+esac
# --- Xterm window measurements ---
#
# Window width is 503 (fixed).
# Vertical line pixel height = 13; misc overhead = 23
# --- Xterm window measurements ---
#
# Window width is 503 (fixed).
# Vertical line pixel height = 13; misc overhead = 23
-xterm="pterm" xgeom=geometry
+: ${term=$(pick_program pterm Eterm xterm)}
+$tt Using terminal $tt
+case "$term" in
+ pterm) t_wd=503 t_lineht=13 t_vextra=23 geom=-geometry;;
+ Eterm) t_wd=504 t_lineht=13 t_vextra=23 geom=-g;;
+ xterm) t_wd=507 t_lineht=13 t_vextra=27 geom=-geometry;;
+esac
# --- GNOME stuff measurements ---
#
# --- GNOME stuff measurements ---
#
# and the toolbar, so we add on some rows which are later mysteriously
# subtracted.
# and the toolbar, so we add on some rows which are later mysteriously
# subtracted.
-declare -i ecols="(xbound - 503 - 34)/492"
-if (( ecols < 2 && xbound > 492 * 2 + 34 )); then
+declare -i ecols="(xbound - t_wd - e_hextra)/e_colwd"
+if (( ecols < 2 && xbound > e_colwd * 2 + e_hextra )); then
ecols=2
elif (( ecols < 1 )); then
ecols=1
fi
ecols=2
elif (( ecols < 1 )); then
ecols=1
fi
-declare -i x="ecols * 492 + 34"
-$emacs -geometry $((ecols * 82 - 2))x$(((XHEIGHT - 52)/13))+0+0&
+declare -i x="ecols * e_colwd + e_hextra"
+noip $emacs -geometry $((ecols * e_colchars + e_cextra))x$(((XHEIGHT - e_vextra)/e_lineht))+0+0&
# --- Now place some xterms ---
#
# --- Now place some xterms ---
#
# xterms.
declare -i n=0 pgx=0 l h y ht
# xterms.
declare -i n=0 pgx=0 l h y ht
-declare -i hstd="35 * 13 + 23" hmin="25 * 13 + 23"
+declare -i hstd="35 * t_lineht + t_vextra" hmin="25 * t_lineht + t_vextra"
- if ((x + 503 > xbound)); then
+ if ((x + t_wd > xbound)); then
if ((n >= 3)); then break; fi
x="pgx + XWIDTH" pgx="pgx + XWIDTH" xbound="xbound + XWIDTH"
fi
y=0 ht=XHEIGHT
while ((ht - hstd >= hmin)); do
if ((n >= 3)); then break; fi
x="pgx + XWIDTH" pgx="pgx + XWIDTH" xbound="xbound + XWIDTH"
fi
y=0 ht=XHEIGHT
while ((ht - hstd >= hmin)); do
- $xterm -$xgeom 80x35+$x+$y&
+ $term $geom 80x35+$x+$y&
y="y + hstd" ht="ht - hstd" n="n + 1"
done
if ((ht >= 2 * hmin)); then h="ht - hmin"; else h=ht; fi
y="y + hstd" ht="ht - hstd" n="n + 1"
done
if ((ht >= 2 * hmin)); then h="ht - hmin"; else h=ht; fi
- l="(h - 23)/13" h="l * 13 + 23"
- $xterm -$xgeom 80x$l+$x+$y&
+ l="(h - t_vextra)/t_lineht" h="l * t_lineht + t_vextra"
+ $term $geom 80x$l+$x+$y&
y="y + h" ht="ht - h" n="n + 1"
if ((ht >= hmin)); then
y="y + h" ht="ht - h" n="n + 1"
if ((ht >= hmin)); then
- $xterm -$xgeom 80x25+$x+$y&
+ $term $geom 80x25+$x+$y&
done
# --- Wait for the world to end ---
done
# --- Wait for the world to end ---
-xwait XWAIT_DIE:XWAIT_DIE_NOW
-eval "$cleanup"
+$xx xwait XWAIT_DIE:XWAIT_DIE_NOW
+$xx eval "$cleanup"