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 ###--------------------------------------------------------------------------
74 ### Iniitial settings.
76 ## Assume X sessions are secure.
77 export __mdw_sechost
="`hostname`"
79 ## Obtain the screen dimensions.
80 case ",$XWIDTH,$XHEIGHT," in
81 *,,*) eval $
(xscsize
-bx
) ;;
83 info
"screen size = $XWIDTH x $XHEIGHT"
86 ## Load the X resource database.
87 run init xrdb
-override
$HOME/.Xdefaults
90 run init xset b
10 2000 50
91 run init xset r rate
500 50
95 xmodmap
-e
'keysym BackSpace = BackSpace BackSpace'
98 case $vnc in no
) run bginit gnome-settings-daemon
;; esac
101 ###--------------------------------------------------------------------------
102 ### Start a window manager.
104 wm
=$
(pick_program window-manager enlightenment e16 twm
)
107 enlightenment
,yes | e16
,yes)
108 wmopts
="$eopts -econfdir $HOME/.enlightenment-vnc"
113 run bginit
$wm $wmopts
115 for i
in $
(seq 10); do
117 if eesh version
>/dev
/null
2>&1; then
124 info
"$wm started ok"
125 run init xsetroot
-cursor_name left_ptr
128 info
"$wm failed to start!"
133 start-window-manager
() {
134 case $
(type -t start-
$wm ||
echo "not-found") in
139 run bginit
$wm $wmopts
144 ###--------------------------------------------------------------------------
145 ### Random useful clients.
147 start-clients-local
() { :; }
149 scsv
=$
(pick_program screensaver gnome-screensaver xscreensaver
)
152 scsvopts
="-no-splash"
160 ## Mail notification.
161 run bginit mail-notification
163 ## Gnome session. With great reluctance. At least it doesn't actually do
165 run bginit gnome-session
167 ## Policykit authentication agent.
168 agent
=/usr
/lib
/policykit-1-gnome
/polkit-gnome-authentication-agent-1
169 if [ -x
$agent ]; then run bginit
$agent; fi
172 case $vnc in no
) run bginit gkrellm
;; esac
177 run init xscreensaver-command
-exit
178 run bginit
$scsv $scsvopts
183 case $vnc in no
) run bginit gnome-panel
;; esac
189 ###--------------------------------------------------------------------------
190 ### Main screen layout.
192 ## Choose appropriate clients.
193 emacs
=$
(pick_program emacs emacs23 emacs22 emacs21 emacs
)
194 term
=$
(pick_program terminal pterm Eterm xterm
)
196 ## Emacs window measurements.
199 e_colwd
=492 e_hextra
=34
200 e_colchars
=82 e_cextra
=-2
201 e_lineht
=13 e_vextra
=52
204 e_colwd
=492 e_hextra
=8
205 e_colchars
=82 e_cextra
=-6
206 e_lineht
=13 e_vextra
=46
210 ## Terminal window measurements.
212 pterm
) t_wd
=504 t_lineht
=13 t_vextra
=23 geom
=-geometry
;;
213 Eterm
) t_wd
=504 t_lineht
=13 t_vextra
=23 geom
=-g
;;
214 xterm
) t_wd
=507 t_lineht
=13 t_vextra
=27 geom
=-geometry
;;
217 ## GNOME stuff measurements.
218 declare -i xbound
="XWIDTH - 113"
220 ## Choose a width for Emacs.
222 ## We'd like it to be as wide as possible, allowing for a column of xterms
223 ## down the right hand side. However, I'd prefer a double-width Emacs to a
224 ## single-width Emacs and xterms. If it's not going to work at all, a single
225 ## Emacs column will have to do. Also, there's a strange thing with Emacs21
226 ## and the toolbar, so we add on some rows which are later mysteriously
229 declare -i ecols
="(xbound - t_wd - e_hextra)/e_colwd"
230 if (( ecols
< 2 && xbound
> e_colwd
* 2 + e_hextra
)); then
232 elif (( ecols
< 1 )); then
237 emacsx
="ecols * e_colchars + e_cextra" \
238 emacsy
="(XHEIGHT - e_vextra)/e_lineht"
241 GDK_NATIVE_WINDOWS
=1 run bgclients noip \
242 $emacs -geometry
${emacsx}x
${emacsy}+0+0
245 ## Now place some xterms.
247 ## A few smaller xterms are in general better than one great big one. 35
248 ## lines is a good height for most terminals. 25 lines is a minimum. The
249 ## strategy for doling out xterms into a column is to make as many 35-liners
250 ## as we can, until the remaining space would be too small for a 25-liner.
251 ## If we can get two 25s out of that then we do (largest first); otherwise
252 ## just make one big one. We stop at the end of a page, once we've made
257 ## Initialize some parameters.
258 declare -i x
="ecols * e_colwd + e_hextra" xb
=xbound
259 declare -i n
=0 pgx
=0 l h y ht
260 declare -i hstd
="35 * t_lineht + t_vextra" hmin
="25 * t_lineht + t_vextra"
265 ## Start a new iteration.
266 if ((x
+ t_wd
> xb
)); then
267 if ((n
>= 3)); then break; fi
268 x
="pgx + XWIDTH" pgx
="pgx + XWIDTH" xb
="xb + XWIDTH"
271 ## Make large xterms.
273 while ((ht
- hstd
>= hmin
)); do
274 run bgclients
$term $geom 80x35
+$x+$y
275 y
="y + hstd" ht
="ht - hstd" n
="n + 1"
278 ## Fill the remaining space.
279 if ((ht
>= 2 * hmin
)); then h
="ht - hmin"; else h
=ht
; fi
280 l
="(h - t_vextra)/t_lineht" h
="l * t_lineht + t_vextra"
281 run bgclients
$term $geom 80x
$l+$x+$y
282 y
="y + h" ht
="ht - h" n
="n + 1"
283 if ((ht
>= hmin
)); then
284 run bgclients
$term $geom 80x25
+$x+$y
291 ###--------------------------------------------------------------------------
295 declare title
=$1 hist
=$2; shift 2
296 cmd
=$
(xgetline
-t
"$title" -p
"_Command:" -Hl
"$HOME/$hist") &&
300 ###--------------------------------------------------------------------------
303 atom
=XINIT_COMMAND
$atomtag
308 info
"waiting on $atom"
309 line
=$
(xatom
wait $atom)
314 xmsg
-I
-t
"xinitrc help" -d
"xinitrc commands" - <<EOF &
316 :emacs :xterms :window-manager :clients
317 :ask-run :ask-command
324 :emacs |
:xterms |
:window-manager |
:clients
)
334 info
"restarting xinitrc"
335 exec "$0" wait nostart
338 req
"Shell command" .cmd.hist xcatch
-FMiscFixed6x13
-- sh
-c
&
341 req
"xinit command" .xinit.hist xatom
set XINIT_COMMAND
$atomtag&
344 xmsg
-E
-t
"xinitrc error" "Unknown command \`$line'" &
357 ###--------------------------------------------------------------------------
358 ### Actually start things up.
360 if [ -f
$HOME/.xinitrc-local
]; then
361 .
$HOME/.xinitrc-local
366 info
"starting standard clients"
374 info
"not starting standard clients"
383 info
"not waiting before exit"
387 ###----- That's all, folks --------------------------------------------------