- some small fixes to make it compile on werider systems.
[wmaker-crm.git] / util / wmaker.inst.in
blob4fc762527fbab69d0eec1ffeba7608ba2aea080b
1 #!/bin/sh
3 # Install Window Maker for the current user
6 # xx herbert
7 if test x"$1" = x"--batch" ; then
8 BATCH="1"
9 else
10 BATCH=""
12 # /xx herbert
14 # directory where system wide configuration is stored
15 GLOBALDIR="#pkgdatadir#"
16 GLOBALDEFDIR="#sysconfdir#"
18 USERDIR=$HOME
20 VERSION="#version#"
22 BINDIR="#bindir#"
24 make_dir() {
25 mkdir $1
26 chmod +rwx $1
29 make_script() {
30 ISCRIPT=$1
32 cat << EOF >> $ISCRIPT
33 # Window Maker default X session startup script
35 PATH="\$PATH:$BINDIR"
37 # If you login from xdm, uncomment this to make error messages appear
38 # in the console window.
40 # tail -f $HOME/.xsession-errors > /dev/console &
42 exec wmaker
44 EOF
45 chmod +rx $ISCRIPT
50 # Copy files considering special cases
52 copy() {
53 source=$1
54 target=$2
55 file=`basename $source`
56 rm -f $target
57 if [ "$file" = "WindowMaker" ]; then
58 sed -e "s|~/GNUstep|$GSDIR|g" $source > $target
59 else
60 if test "x$GNUSTEP_USER_ROOT" = "x"; then
61 sed -e "s:#wmdatadir#:$GLOBALDIR:g" \
62 $source > $target
63 else
64 sed -e "s|\$HOME/GNUstep|$GSDIR|g" \
65 -e "s:#wmdatadir#:$GLOBALDIR:g" \
66 $source > $target
73 echo "Installing WindowMaker $VERSION for current user..."
76 if [ ! -d $GLOBALDIR ]; then
77 echo "Could not find global data files"
78 echo "Make sure you have installed Window Maker correctly"
79 exit 1
82 if [ ! -d $GLOBALDEFDIR ]; then
83 echo "Could not find global configurations files"
84 echo "Make sure you have installed Window Maker correctly"
85 exit 1
88 if [ ! -d "$USERDIR" ]; then
89 echo "Could not find user directory $USERDIR"
90 exit 1
94 if test "x$GNUSTEP_USER_ROOT" = "x"; then
95 cd $USERDIR
96 GSDIR=$USERDIR/GNUstep
97 if [ ! -d $GSDIR ]; then
98 echo "Creating $GSDIR user directory"
99 make_dir $GSDIR
101 else
102 GSDIR=$GNUSTEP_USER_ROOT
103 if [ ! -d $GSDIR ]; then
104 echo "Directory specified in GNUSTEP_USER_ROOT environment variable does not exist"
105 exit 1
107 cd $GSDIR
108 cd ..
112 if [ ! -d "$GSDIR/.AppInfo" ]; then
113 make_dir $GSDIR/.AppInfo
116 if [ ! -d "$GSDIR/Defaults" ]; then
117 make_dir $GSDIR/Defaults
120 echo "Copying defaults database..."
122 FILES=`(cd $GLOBALDEFDIR;ls -d *)`
123 all=""
124 for i in $FILES; do
125 if [ ! -d $GLOBALDEFDIR/$i ]; then
126 if [ -f $GSDIR/Defaults/$i -a -z "$BATCH" ]; then
127 echo "The configuration file \"$i\" already exists in your defaults database."
128 echo "Do you wish to replace it? <y/n/a> [n] $all"
129 if [ "$all" != "a" ]; then
130 read foo
131 if [ "$foo" = "a" -o "$foo" = "A" ]; then
132 all="a"
135 if [ "$foo" = "y" -o "$foo" = "Y" -o "$all" = "a" ]; then
136 copy $GLOBALDEFDIR/$i $GSDIR/Defaults/$i
138 else
139 copy $GLOBALDEFDIR/$i $GSDIR/Defaults/$i
142 done
145 if [ ! -d "$GSDIR/Library/Icons/" ]; then
146 echo "Creating icon library directory $GSDIR/Library/Icons"
147 if [ ! -d $GSDIR/Library ]; then
148 make_dir $GSDIR/Library
150 make_dir $GSDIR/Library/Icons
154 if [ ! -d "$GSDIR/Library/WindowMaker/" ]; then
155 echo "Creating WindowMaker data library directory $GSDIR/Library/WindowMaker"
156 if [ ! -d $GSDIR/Library ]; then
157 make_dir $GSDIR/Library
159 make_dir $GSDIR/Library/WindowMaker
162 if [ ! -d "$GSDIR/Library/WindowMaker/Styles" ]; then
163 echo "Creating style library $GSDIR/Library/WindowMaker/Styles"
164 make_dir $GSDIR/Library/WindowMaker/Styles
168 if [ ! -d "$GSDIR/Library/WindowMaker/Themes" ]; then
169 echo "Creating theme library $GSDIR/Library/WindowMaker/Themes"
170 make_dir $GSDIR/Library/WindowMaker/Themes
175 if [ ! -d "$GSDIR/Library/WindowMaker/Backgrounds" ]; then
176 echo "Creating bg image library $GSDIR/Library/WindowMaker/Backgrounds"
177 make_dir $GSDIR/Library/WindowMaker/Backgrounds
178 else
179 echo "Default Backgrounds directory already exists. Skipping..."
183 if [ ! -d "$GSDIR/Library/WindowMaker/IconSets" ]; then
184 echo "Creating icon setup library $GSDIR/Library/WindowMaker/IconSets"
185 make_dir $GSDIR/Library/WindowMaker/IconSets
186 else
187 echo "Default IconSets directory already exists. Skipping..."
191 if [ ! -d "$GSDIR/Library/WindowMaker/Pixmaps" ]; then
192 echo "Creating pixmap library $GSDIR/Library/WindowMaker/Pixmaps"
193 make_dir $GSDIR/Library/WindowMaker/Pixmaps
194 else
195 echo "Default Pixmaps directory already exists. Skipping..."
199 if [ ! -d "$GSDIR/Library/WindowMaker/Sounds" ]; then
200 echo "Creating sound library $GSDIR/Library/WindowMaker/Sounds"
201 make_dir $GSDIR/Library/WindowMaker/Sounds
202 else
203 echo "Default Sounds directory already exists. Skipping..."
207 if [ ! -d "$GSDIR/Library/WindowMaker/SoundSets" ]; then
208 echo "Creating sound set library $GSDIR/Library/WindowMaker/SoundSets"
209 make_dir $GSDIR/Library/WindowMaker/SoundSets
210 else
211 echo "Default SoundSets directory already exists. Skipping..."
215 if test -z "#LITE#" ; then
216 FILES=`(cd $GLOBALDIR; ls menu menu.* plmenu plmenu.?? wmmacros)`
217 for i in $FILES; do
218 # xx herbert
219 if [ -f "$GSDIR/Library/WindowMaker/$i" -a -z "$BATCH" ]; then
220 # /xx herbert
221 echo "The file \"$i\" already exists in $GSDIR/Library/WindowMaker"
222 echo "Do you wish to replace it? <y/n/a> [n] $all"
223 if [ "$all" != "a" ]; then
224 read foo
225 if [ "$foo" = "a" -o "$foo" = "A" ]; then
226 all="a"
229 if [ "$foo" = "y" -o "$foo" = "Y" -o "$foo" = "a" ]; then
230 copy $GLOBALDIR/$i $GSDIR/Library/WindowMaker/$i
232 else
233 copy $GLOBALDIR/$i $GSDIR/Library/WindowMaker/$i
235 done
238 cp $GLOBALDIR/README.themes $GSDIR/Library/WindowMaker
239 cp $GLOBALDIR/README $GSDIR/Library/WindowMaker
241 test -f ~$GSDIR/Library/WindowMaker/autostart || \
242 cp $GLOBALDIR/autostart.sh $GSDIR/Library/WindowMaker/autostart
243 chmod +rx $GSDIR/Library/WindowMaker/autostart
245 test -f ~$GSDIR/Library/WindowMaker/exitscript || \
246 cp $GLOBALDIR/exitscript.sh $GSDIR/Library/WindowMaker/exitscript
247 chmod +rx $GSDIR/Library/WindowMaker/exitscript
249 # xx herbert
250 if test -n "$BATCH" ; then
251 echo "Installation Finished"
252 exit 0
254 # /xx herbert
258 #######################
260 DATE=`date +%b%d.%T`
262 show_end_message() {
264 echo
265 echo "Installation Finished"
266 echo
267 if test -z "#LITE#" ; then
268 echo "There are menus in 2 different file formats. The plain text format and"
269 echo "the property list format. The plain text format is more flexible, but"
270 echo "the menu in the property list format can be edited graphically. The"
271 echo "menu that will be used by default is the property list one. Read"
272 echo "$GSDIR/Library/WindowMaker/README for information on how to change it."
273 else
274 echo "Your copy of Window Maker is configured especially for KDE."
275 echo "Window Maker application menus are not available."
279 wmaker_found=0
280 for xinit in .xinitrc .Xclients .xsession; do
281 test ! -f "$HOME/$xinit" && continue
282 res="`grep wmaker $HOME/$xinit`"
283 if test "x$res" != x; then
284 wmaker_found=1
285 break
287 done
288 if test $wmaker_found = 1; then
289 echo "Found Window Maker to already be your default window manager."
290 show_end_message
291 exit 0
295 trap "show_end_message;exit" 2
297 echo
298 echo "Now the .xinitrc, .Xclients or .xsession script must be updated so that"
299 echo "it calls wmaker when you start an X session."
300 echo "Type the name of the file that must be changed (normally .xinitrc)."
301 echo "If the file already exists, it will be backed up with a .old.$DATE "
302 echo "extension"
303 echo "If you want to edit it by hand, hit <Control>-C now."
304 read file
306 if test "x$file" = "x"; then
307 echo "Using .xinitrc as a default value"
308 file=.xinitrc
311 if [ -f $USERDIR/$file ]; then
312 mv $USERDIR/$file $USERDIR/$file.old.$DATE
315 make_script $USERDIR/$file
317 show_end_message