bash_profile: Select Emacs 22 by preference.
[profile] / xinitrc
CommitLineData
f617db13
MW
1#! /bin/bash
2
3xrdb -override $HOME/.Xdefaults
ec2de2b7 4: ${VNCSESSION=false}
f617db13
MW
5export __mdw_sechost="`hostname`"
6
7# --- Do some fiddling ---
8
9cleanup=":"
10xset b 10 2000 50
11xset r rate 500 50
12xset m 1 1
13gnome-settings-daemon&
14mail-notification&
ec2de2b7 15$VNCSESSION || gkrellm&
f617db13
MW
16eval `xscsize -bx`
17
18# --- Crank up ESD ---
19
20if ! [ -r /tmp/.esd/socket ]; then
21 esd -nobeeps -as 10&
22 cleanup="$cleanup; kill $!"
23fi
24
25# --- Start a nice window manager ---
26
27enlightenment $EOPTS&
28
29# --- Crank up a screenlock program ---
30
ec2de2b7 31if ! $VNCSESSION; then
f617db13
MW
32 xscreensaver-command -exit
33 xscreensaver -no-splash&
34fi
35gnome-panel&
f617db13
MW
36
37# --- Emacs window measurements ---
38#
39# Horizontal column pixel width = 492; window manager overhead = 34
40# Column character width = 82; Emacs magic overhead = -2
41# Vertical line pixel height = 13; misc overhead = 52
42
43emacs="noip emacs"
44
45# --- Xterm window measurements ---
46#
1c6b19d4 47# Window width is 503 (fixed).
f617db13
MW
48# Vertical line pixel height = 13; misc overhead = 23
49
1c6b19d4 50xterm="pterm" xgeom=geometry
f617db13
MW
51
52# --- GNOME stuff measurements ---
53#
54# GNOME panel width = 113
55
56declare -i xbound="XWIDTH - 113"
57
58# --- Choose a width for Emacs ---
59#
60# We'd like it to be as wide as possible, allowing for a column of xterms
61# down the right hand side. However, I'd prefer a double-width Emacs to a
62# single-width Emacs and xterms. If it's not going to work at all, a single
63# Emacs column will have to do. Also, there's a strange thing with Emacs21
64# and the toolbar, so we add on some rows which are later mysteriously
65# subtracted.
66
1c6b19d4 67declare -i ecols="(xbound - 503 - 34)/492"
f617db13
MW
68if (( ecols < 2 && xbound > 492 * 2 + 34 )); then
69 ecols=2
70elif (( ecols < 1 )); then
71 ecols=1
72fi
73
74declare -i x="ecols * 492 + 34"
75$emacs -geometry $((ecols * 82 - 2))x$(((XHEIGHT - 52)/13))+0+0&
76
77# --- Now place some xterms ---
78#
79# A few smaller xterms are in general better than one great big one. 35
80# lines is a good height for most terminals. 25 lines is a minimum. The
81# strategy for doling out xterms into a column is to make as many 35-liners
82# as we can, until the remaining space would be too small for a 25-liner. If
83# we can get two 25s out of that then we do (largest first); otherwise just
84# make one big one. We stop at the end of a page, once we've made three
85# xterms.
86
87declare -i n=0 pgx=0 l h y ht
88declare -i hstd="35 * 13 + 23" hmin="25 * 13 + 23"
89while true; do
1c6b19d4 90 if ((x + 503 > xbound)); then
f617db13
MW
91 if ((n >= 3)); then break; fi
92 x="pgx + XWIDTH" pgx="pgx + XWIDTH" xbound="xbound + XWIDTH"
93 fi
94 y=0 ht=XHEIGHT
95 while ((ht - hstd >= hmin)); do
96 $xterm -$xgeom 80x35+$x+$y&
97 y="y + hstd" ht="ht - hstd" n="n + 1"
98 done
99 if ((ht >= 2 * hmin)); then h="ht - hmin"; else h=ht; fi
100 l="(h - 23)/13" h="l * 13 + 23"
101 $xterm -$xgeom 80x$l+$x+$y&
102 y="y + h" ht="ht - h" n="n + 1"
103 if ((ht >= hmin)); then
104 $xterm -$xgeom 80x25+$x+$y&
105 n="n + 1"
106 fi
1c6b19d4 107 x="x + 503"
f617db13
MW
108done
109
110# --- Wait for the world to end ---
111
112xwait XWAIT_DIE:XWAIT_DIE_NOW
113eval "$cleanup"