Initial import of my profile.
[profile] / xinitrc
CommitLineData
f617db13
MW
1#! /bin/bash
2
3xrdb -override $HOME/.Xdefaults
4export __mdw_sechost="`hostname`"
5
6# --- Do some fiddling ---
7
8cleanup=":"
9xset b 10 2000 50
10xset r rate 500 50
11xset m 1 1
12gnome-settings-daemon&
13mail-notification&
14gkrellm&
15eval `xscsize -bx`
16
17# --- Crank up ESD ---
18
19if ! [ -r /tmp/.esd/socket ]; then
20 esd -nobeeps -as 10&
21 cleanup="$cleanup; kill $!"
22fi
23
24# --- Start a nice window manager ---
25
26enlightenment $EOPTS&
27
28# --- Crank up a screenlock program ---
29
30if ${SCSAVE-true}; then
31 xscreensaver-command -exit
32 xscreensaver -no-splash&
33fi
34gnome-panel&
35mail-notification&
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#
47# Window width is 504 (fixed).
48# Vertical line pixel height = 13; misc overhead = 23
49
50xterm="Eterm" xgeom=-geometry
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
67declare -i ecols="(xbound - 504 - 34)/492"
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
90 if ((x + 504 > xbound)); then
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
107 x="x + 504"
108done
109
110# --- Wait for the world to end ---
111
112xwait XWAIT_DIE:XWAIT_DIE_NOW
113eval "$cleanup"