5 ###--------------------------------------------------------------------------
8 ## Progress indicators.
11 case $info in yes) echo "- $*" >&2 ;; esac
19 case $what in bg*) bg=yes what
=${what#bg} ;; esac
33 if type -t
>/dev
/null
"$i"; then choice
=$i; break; fi
35 info
"pick $what = $choice"
39 ###--------------------------------------------------------------------------
63 tag
=*) atomtag
=/${opt#tag=} ;;
66 info | run | start |
wait | vnc
) eval "$opt=yes" ;;
67 noinfo | norun | nostart | nowait | novnc
) eval "${opt#no}=no" ;;
69 *) echo "unknown option $opt" >&2; exit 1 ;;
73 ###--------------------------------------------------------------------------
76 if [ -r
$HOME/.xinitrc-prehook
]; then
77 .
$HOME/.xinitrc-prehook
80 ###--------------------------------------------------------------------------
81 ### Iniitial settings.
83 ## Assume X sessions are secure.
84 export __mdw_sechost
="`hostname`"
86 ## Obtain the screen dimensions.
87 case ",$XWIDTH,$XHEIGHT," in
88 *,,*) eval $
(xscsize
-bx
) ;;
90 info
"screen size = $XWIDTH x $XHEIGHT"
93 ## Load the X resource database.
94 run init xrdb
-override
$HOME/.Xdefaults
97 run init xset b
5 2000 50
98 run init xset r rate
500 50
102 xmodmap
$HOME/.xmodmap
103 if [ -r
$HOME/.xmodmap-local
]; then
104 xmodmap
$HOME/.xmodmap-local
108 ###--------------------------------------------------------------------------
109 ### Start a window manager.
111 wm
=$
(pick_program window-manager e16 compiz enlightenment e17 twm
)
114 enlightenment
,yes | e16
,yes)
115 wmopts
="$eopts -econfdir $HOME/.enlightenment-vnc"
120 run bginit
$wm $wmopts
122 for i
in $
(seq 10); do
124 if eesh version
>/dev
/null
2>&1; then
131 info
"$wm started ok"
132 run init xsetroot
-cursor_name left_ptr
135 info
"$wm failed to start!"
140 start-window-manager
() {
141 case $
(type -t start-
$wm ||
echo "not-found") in
146 run bginit
$wm $wmopts
151 ###--------------------------------------------------------------------------
152 ### Random useful clients.
154 start-clients-local
() { :; }
159 case "$vnc,$(gnome-session --version 2>&1)" in
160 no
,gnome-session\
2.3[2-9].
* | \
161 no
,gnome-session\
2.4[0-9].
* | \
162 no
,gnome-session\
2.
[1-9][0-9][0-9]*)
163 run bginit gnome-session
--session mdw
166 run bginit gnome-session
174 ###--------------------------------------------------------------------------
175 ### Main screen layout.
177 ## Choose appropriate clients.
178 emacs
=$
(pick_program emacs emacs23 emacs22 emacs21 emacs
)
179 term
=$
(pick_program terminal pterm Eterm xterm
)
181 ## Emacs window measurements.
184 e_colwd
=492 e_hextra
=34
185 e_colchars
=82 e_cextra
=-2
186 e_lineht
=13 e_vextra
=52
189 e_colwd
=492 e_hextra
=8
190 e_colchars
=82 e_cextra
=-6
191 e_lineht
=13 e_vextra
=46
195 ## Terminal window measurements.
197 pterm
) t_wd
=504 t_lineht
=13 t_vextra
=23 geom
=-geometry
;;
198 Eterm
) t_wd
=504 t_lineht
=13 t_vextra
=23 geom
=-g
;;
199 xterm
) t_wd
=507 t_lineht
=13 t_vextra
=27 geom
=-geometry
;;
202 ## GNOME stuff measurements.
203 declare -i xbound
="XWIDTH - 113"
205 ## Choose a width for Emacs.
207 ## We'd like it to be as wide as possible, allowing for a column of xterms
208 ## down the right hand side. However, I'd prefer a double-width Emacs to a
209 ## single-width Emacs and xterms. If it's not going to work at all, a single
210 ## Emacs column will have to do. Also, there's a strange thing with Emacs21
211 ## and the toolbar, so we add on some rows which are later mysteriously
214 declare -i ecols
="(xbound - t_wd - e_hextra)/e_colwd"
215 if (( ecols
< 2 && xbound
> e_colwd
* 2 + e_hextra
)); then
217 elif (( ecols
< 1 )); then
222 emacsx
="ecols * e_colchars + e_cextra" \
223 emacsy
="(XHEIGHT - e_vextra)/e_lineht"
226 GDK_NATIVE_WINDOWS
=1 run bgclients noip \
227 $emacs -geometry
${emacsx}x
${emacsy}+0+0
230 ## Now place some xterms.
232 ## A few smaller xterms are in general better than one great big one. 35
233 ## lines is a good height for most terminals. 25 lines is a minimum. The
234 ## strategy for doling out xterms into a column is to make as many 35-liners
235 ## as we can, until the remaining space would be too small for a 25-liner.
236 ## If we can get two 25s out of that then we do (largest first); otherwise
237 ## just make one big one. We stop at the end of a page, once we've made
242 ## Initialize some parameters.
243 declare -i x
="ecols * e_colwd + e_hextra" xb
=xbound
244 declare -i n
=0 pgx
=0 l h y ht
245 declare -i hstd
="35 * t_lineht + t_vextra" hmin
="25 * t_lineht + t_vextra"
250 ## Start a new iteration.
251 if ((x
+ t_wd
> xb
)); then
252 if ((n
>= 3)); then break; fi
253 x
="pgx + XWIDTH" pgx
="pgx + XWIDTH" xb
="xb + XWIDTH"
256 ## Make large xterms.
258 while ((ht
- hstd
>= hmin
)); do
259 run bgclients
$term $geom 80x35
+$x+$y
260 y
="y + hstd" ht
="ht - hstd" n
="n + 1"
263 ## Fill the remaining space.
264 if ((ht
>= 2 * hmin
)); then h
="ht - hmin"; else h
=ht
; fi
265 l
="(h - t_vextra)/t_lineht" h
="l * t_lineht + t_vextra"
266 run bgclients
$term $geom 80x
$l+$x+$y
267 y
="y + h" ht
="ht - h" n
="n + 1"
268 if ((ht
>= hmin
)); then
269 run bgclients
$term $geom 80x25
+$x+$y
276 ###--------------------------------------------------------------------------
280 declare title
=$1 hist
=$2; shift 2
281 cmd
=$
(xgetline
-t
"$title" -p
"_Command:" -Hl
"$HOME/$hist") &&
285 ###--------------------------------------------------------------------------
288 atom
=XINIT_COMMAND
$atomtag
293 info
"waiting on $atom"
294 line
=$
(xatom
wait $atom)
299 xmsg
-I
-t
"xinitrc help" -d
"xinitrc commands" - <<EOF &
301 :emacs :xterms :window-manager :clients
302 :ask-run :ask-command
309 :emacs |
:xterms |
:window-manager |
:clients
)
319 info
"restarting xinitrc"
320 exec "$0" wait nostart
323 req
"Shell command" .cmd.hist xcatch
-FMiscFixed6x13
-- sh
-c
&
326 req
"xinit command" .xinit.hist xatom
set XINIT_COMMAND
$atomtag&
329 xmsg
-E
-t
"xinitrc error" "Unknown command \`$line'" &
342 ###--------------------------------------------------------------------------
343 ### Gnome session care and feeding.
345 session-running-p
() {
346 dbus-send
--session
--print-reply
--dest
=org.freedesktop.DBus
/ \
347 org.freedesktop.DBus.GetNameOwner string
:org.gnome.SessionManager \
351 kill-gnome-session
() {
352 if session-running-p
; then
353 info
"killing Gnome session manager"
354 dbus-send
--session \
355 --dest
=org.gnome.SessionManager
/org
/gnome
/SessionManager \
356 org.gnome.SessionManager.Logout uint32
:2
357 for i
in 1 2 3 4 5; do
359 if ! session-running-p
; then break; fi
364 ###--------------------------------------------------------------------------
365 ### Actually start things up.
367 if [ -f
$HOME/.xinitrc-local
]; then
368 .
$HOME/.xinitrc-local
373 info
"starting standard clients"
381 info
"not starting standard clients"
391 info
"not waiting before exit"
395 ###----- That's all, folks --------------------------------------------------