1 |
#!/bin/bash |
2 |
# |
3 |
# RunWM - this is a script used to launch window managers |
4 |
# |
5 |
# |
6 |
|
7 |
WM_CHOICE= |
8 |
KNOW_WM="no" |
9 |
|
10 |
if [ -n "$1" ] ; then |
11 |
case "$1" in |
12 |
--afterstep | --AfterStep | \ |
13 |
--windowmaker | --wmaker | --WindowMaker | \ |
14 |
--fvwm95 | --Fvwm95 | \ |
15 |
--fvwmMWM | --fvwmmwm | \ |
16 |
--MWM | --Mwm | --mwm ) |
17 |
KNOW_WM="yes" |
18 |
WM_CHOICE=$1 |
19 |
shift |
20 |
;; |
21 |
--help) |
22 |
echo "Usage: $0 [window_manager] where window_manager can be" |
23 |
echo " --AfterStep start Afterstep" |
24 |
echo " --WindowMaker start WindowMaker" |
25 |
echo " --Fvwm95 start Fvwm2 with '95 interface" |
26 |
echo " --FvwmMWM start Fvwm2 with MWM interface" |
27 |
echo |
28 |
exit 0 |
29 |
;; |
30 |
*) |
31 |
KNOW_WM="no" |
32 |
WM_CHOICE= |
33 |
;; |
34 |
esac |
35 |
fi |
36 |
|
37 |
# Now, some braindead window managers don't know how to pass arguments to another |
38 |
# wm when doing a Restart... (fvwm2 is one of them) |
39 |
|
40 |
if [ -z "$WM_CHOICE" ] ; then |
41 |
#try to see if we are called funny names... |
42 |
case "$0" in |
43 |
*RunWM.Fvwm95) |
44 |
WM_CHOICE="--Fvwm95" |
45 |
KNOW_WM="yes" |
46 |
;; |
47 |
*RunWM.MWM) |
48 |
WM_CHOICE="--FvwmMWM" |
49 |
KNOW_WM="yes" |
50 |
;; |
51 |
*RunWM.AfterStep) |
52 |
WM_CHOICE="--AfterStep" |
53 |
KNOW_WM="yes" |
54 |
;; |
55 |
*RunWM.WindowMaker) |
56 |
WM_CHOICE="--WindowMaker" |
57 |
KNOW_WM="yes" |
58 |
;; |
59 |
esac |
60 |
fi |
61 |
|
62 |
if [ "$KNOW_WM" = "no" ] ; then |
63 |
if [ -f $HOME/.wm_style ] ; then |
64 |
WM_CHOICE="--$(cat $HOME/.wm_style)" |
65 |
else |
66 |
WM_CHOICE="--Fvwm95" |
67 |
fi |
68 |
fi |
69 |
|
70 |
############### FUNCTIONS FOR WINDOW MANAGERS ############################ |
71 |
# |
72 |
### |
73 |
# |
74 |
|
75 |
function Start_Fvwm95 () { |
76 |
local RCFILE |
77 |
local FVWMOPTIONS |
78 |
local FVWMVER |
79 |
# first, find an M4-enabled config file (such as |
80 |
# the one from AnotherLevel) for fvwm2 or fvwm95. |
81 |
RCFILE="" |
82 |
for tryfile in "$HOME/.fvwm2rc.m4" \ |
83 |
"/etc/X11/AnotherLevel/fvwm2rc.m4"; do |
84 |
if [ -f "$tryfile" ]; then |
85 |
RCFILE="$tryfile" |
86 |
break |
87 |
fi |
88 |
done |
89 |
|
90 |
# if it really exists, use it; if not, fvwm2 or fvwm95 will |
91 |
# automagically look for a config file in the regular places. |
92 |
if [ -n "$RCFILE" ]; then |
93 |
FVWMOPTIONS="-cmd 'FvwmM4 -debug $RCFILE'" |
94 |
else |
95 |
FVWMOPTIONS="" |
96 |
fi |
97 |
|
98 |
# TheNextLevel is supposed to work with both fvwm95 and fvwm2 |
99 |
for FVWMVER in 2 95 95-2; do |
100 |
if [ -n "$(type -path fvwm${FVWMVER})" ]; then |
101 |
env > "$HOME"/Xrootenv.0 |
102 |
# if this works, we stop here |
103 |
eval "exec fvwm${FVWMVER} ${FVWMOPTIONS}" > "$HOME"/.FVWM${FVWMVER}-errors 2>&1 |
104 |
fi |
105 |
done |
106 |
cat >&2 <<EOF |
107 |
WARNING: You selected Fvwm2 as your window manager, but your installation |
108 |
does not appear to be functional. The executable /usr/bin/fvwm2 was |
109 |
not found on your system. |
110 |
EOF |
111 |
echo "RESUMING with TWM..." >&2 |
112 |
xvt & |
113 |
eval "exec twm" > $HOME/.TWM-errors 2>&1 |
114 |
} |
115 |
|
116 |
# |
117 |
### |
118 |
# |
119 |
|
120 |
function Start_AfterStep () { |
121 |
# we have to start up afterstep |
122 |
if [ -x /usr/bin/afterstep ] ; then |
123 |
mkdir -p $HOME/GNUstep/Library/AfterStep |
124 |
wmconfig --output=afterstep --directories 2>/dev/null |
125 |
env > "$HOME"/Xrootenv.0 |
126 |
# if this works, we stop here |
127 |
eval "exec /usr/bin/afterstep" > "$HOME"/.AfterStep-errors 2>&1 |
128 |
else |
129 |
cat <<EOF |
130 |
WARNING: You selected AfterStep as your window manager, but your installation |
131 |
of AfterStep does not appear to be functional. Either /usr/bin/afterstep |
132 |
was not found or /usr/share/afterstep directory is incomplete. |
133 |
EOF |
134 |
fi |
135 |
echo "RESUMING with Fvwm2 (95 look)" >&2 |
136 |
Start_Fvwm95 |
137 |
} |
138 |
|
139 |
# |
140 |
### |
141 |
# |
142 |
|
143 |
function Start_WindowMaker () { |
144 |
if [ -x /usr/bin/wmaker.inst -a -d /usr/share/WindowMaker ] ; then |
145 |
[ -d $HOME/GNUstep ] || /usr/bin/wmaker.inst --batch |
146 |
env > "$HOME"/Xrootenv.0 |
147 |
eval "exec /usr/bin/wmaker" > "$HOME"/.WindowMaker-errors 2>&1 |
148 |
else |
149 |
cat <<EOF |
150 |
WARNING: You selected WindowMaker as your window manager, but your |
151 |
installation of WindowMaker does not appear to be functional. Either |
152 |
/usr/bin/wmaker was not found or /usr/share/WindowMaker directory |
153 |
is missing. |
154 |
EOF |
155 |
fi |
156 |
echo "RESUMING with Fvwm2 (95 look)" >&2 |
157 |
Start_Fvwm95 |
158 |
} |
159 |
|
160 |
# |
161 |
### |
162 |
# |
163 |
|
164 |
# there is not really any difference between this and the previous one |
165 |
# but we stay prepared... :-) |
166 |
function Start_MWM () { |
167 |
Start_Fvwm95 $* |
168 |
} |
169 |
|
170 |
############################################################################## |
171 |
|
172 |
################### THE REAL WORK IS DNE HERE ################################ |
173 |
case "$WM_CHOICE" in |
174 |
--afterstep | --AfterStep) |
175 |
echo "AfterStep" > $HOME/.wm_style |
176 |
Start_AfterStep |
177 |
exit 0; |
178 |
;; |
179 |
--windowmaker | --wmaker | --WindowMaker) |
180 |
echo "WindowMaker" > $HOME/.wm_style |
181 |
Start_WindowMaker |
182 |
exit 0; |
183 |
;; |
184 |
--fvwm95 | --Fvwm95) |
185 |
echo "Fvwm95" > $HOME/.wm_style |
186 |
Start_Fvwm95 |
187 |
exit 0 |
188 |
;; |
189 |
--MWM | --Mwm | --mwm | \ |
190 |
--FvwmMWM | --fvwmmwm) |
191 |
echo "MWM" > $HOME/.wm_style |
192 |
Start_MWM |
193 |
exit 0; |
194 |
;; |
195 |
*) |
196 |
echo "This window manager ($WM_CHOICE) is unknown to me." |
197 |
$0 --help |
198 |
exit -1 |
199 |
;; |
200 |
esac |
201 |
|
202 |
if [ "$KNOWN_WM" = "yes" ] ; then |
203 |
cat <<EOF |
204 |
|
205 |
The window manager you have requested ($WM_CHOICE) could not be started. |
206 |
EOF |
207 |
else |
208 |
cat <<EOF |
209 |
|
210 |
The default window manager ($WM_CHOICE) could not be started. You have |
211 |
selected this window manager in your $HOME/.wm_style file or it was |
212 |
selected as the default window manager by the system administrator. |
213 |
EOF |
214 |
fi |
215 |
cat <<EOF |
216 |
Check your settings and try again. |
217 |
EOF |
218 |
|
219 |
exit -1; |
220 |
################# This is it ######################### |