Update for 0.51.0
[wmaker-crm.git] / util / wmaker.inst.in
blob4d691682ae97c772cab63c2945f1cff2f254ff2b
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#"
17 USERDIR=$HOME
19 VERSION="#version#"
21 BINDIR="#bindir#"
23 make_dir() {
24 mkdir $1
25 chmod +rw $1
28 make_script() {
29 ISCRIPT=$1
31 cat << EOF >> $ISCRIPT
32 # Window Maker default X session startup script
34 PATH="\$PATH:$BINDIR"
36 # If you login from xdm, uncomment this to make error messages appear
37 # in the console window.
39 # tail -f $HOME/.xsession-errors > /dev/console
41 exec wmaker
43 EOF
44 chmod +rx $ISCRIPT
49 # Copy files considering special cases
51 copy() {
52 source=$1
53 target=$2
54 file=`basename $source`
55 rm -f $target
56 if [ "$file" = "WMRootMenu" ]; then
57 echo \"$GSDIR/Library/WindowMaker/menu\" > \
58 $target
59 elif [ "$file" = "WindowMaker" ]; then
60 sed -e "s|~/GNUstep|$GSDIR|g" $source > $target
61 else
62 if test "x$GNUSTEP_USER_ROOT" = "x"; then
63 sed -e "s:#wmdatadir#:$GLOBALDIR:g" \
64 -e "s://:/:g" \
65 $source > $target
66 else
67 sed -e "s|~/GNUstep|$GSDIR|g" \
68 -e "s:#wmdatadir#:$GLOBALDIR:g" \
69 -e "s://:/:g" \
70 $source > $target
77 echo "Installing WindowMaker $VERSION for current user..."
80 if [ ! -d $GLOBALDIR ]; then
81 echo "Could not find global configurations files"
82 echo "Make sure you have installed Window Maker correctly"
83 exit 1
86 if [ ! -d "$USERDIR" ]; then
87 echo "Could not find user directory $USERDIR"
88 exit 1
92 if test "x$GNUSTEP_USER_ROOT" = "x"; then
93 cd $USERDIR
94 GSDIR=$USERDIR/GNUstep
95 if [ ! -d $GSDIR ]; then
96 echo "Creating $GSDIR user directory"
97 make_dir $GSDIR
99 else
100 GSDIR=$GNUSTEP_USER_ROOT
101 if [ ! -d $GSDIR ]; then
102 echo "Directory specified in GNUSTEP_USER_ROOT environment variable does not exist"
103 exit 1
105 cd $GSDIR
106 cd ..
110 if [ ! -d "$GSDIR/.AppInfo" ]; then
111 make_dir $GSDIR/.AppInfo
114 if [ ! -d "$GSDIR/Defaults" ]; then
115 make_dir $GSDIR/Defaults
118 echo "Copying defaults database..."
120 FILES=`(cd $GLOBALDIR/Defaults;ls *)`
121 all=""
122 for i in $FILES; do
123 # xx herbert
124 if [ -f $GSDIR/Defaults/$i -a -z "$BATCH" ]; then
125 # /xx herbert
126 echo "The configuration file \"$i\" already exists in your defaults database."
127 echo "Do you wish to replace it? <y/n/a> [n] $all"
128 if [ "$all" != "a" ]; then
129 read foo
130 if [ "$foo" = "a" -o "$foo" = "A" ]; then
131 all="a"
134 if [ "$foo" = "y" -o "$foo" = "Y" -o "$all" = "a" ]; then
135 copy $GLOBALDIR/Defaults/$i $GSDIR/Defaults/$i
137 else
138 copy $GLOBALDIR/Defaults/$i $GSDIR/Defaults/$i
140 done
143 if [ ! -d "$GSDIR/Library/Icons/" ]; then
144 echo "Creating icon library directory $GSDIR/Library/Icons"
145 if [ ! -d $GSDIR/Library ]; then
146 make_dir $GSDIR/Library
148 make_dir $GSDIR/Library/Icons
152 if [ ! -d "$GSDIR/Library/WindowMaker/" ]; then
153 echo "Creating WindowMaker data library directory $GSDIR/Library/WindowMaker"
154 if [ ! -d $GSDIR/Library ]; then
155 make_dir $GSDIR/Library
157 make_dir $GSDIR/Library/WindowMaker
160 if [ ! -d "$GSDIR/Library/WindowMaker/Styles" ]; then
161 echo "Creating style library $GSDIR/Library/WindowMaker/Styles"
162 make_dir $GSDIR/Library/WindowMaker/Styles
166 if [ ! -d "$GSDIR/Library/WindowMaker/Themes" ]; then
167 echo "Creating theme library $GSDIR/Library/WindowMaker/Themes"
168 make_dir $GSDIR/Library/WindowMaker/Themes
173 if [ ! -d "$GSDIR/Library/WindowMaker/Backgrounds" ]; then
174 echo "Creating bg image library $GSDIR/Library/WindowMaker/Backgrounds"
175 make_dir $GSDIR/Library/WindowMaker/Backgrounds
176 else
177 echo "Default Backgrounds directory already exists. Skipping..."
181 if [ ! -d "$GSDIR/Library/WindowMaker/IconSets" ]; then
182 echo "Creating icon setup library $GSDIR/Library/WindowMaker/IconSets"
183 make_dir $GSDIR/Library/WindowMaker/IconSets
184 else
185 echo "Default IconSets directory already exists. Skipping..."
189 if [ ! -d "$GSDIR/Library/WindowMaker/Pixmaps" ]; then
190 echo "Creating pixmap library $GSDIR/Library/WindowMaker/Pixmaps"
191 make_dir $GSDIR/Library/WindowMaker/Pixmaps
192 else
193 echo "Default Pixmaps directory already exists. Skipping..."
197 if [ ! -d "$GSDIR/Library/WindowMaker/Sounds" ]; then
198 echo "Creating sound library $GSDIR/Library/WindowMaker/Sounds"
199 make_dir $GSDIR/Library/WindowMaker/Sounds
200 else
201 echo "Default Sounds directory already exists. Skipping..."
205 if [ ! -d "$GSDIR/Library/WindowMaker/SoundSets" ]; then
206 echo "Creating sound set library $GSDIR/Library/WindowMaker/SoundSets"
207 make_dir $GSDIR/Library/WindowMaker/SoundSets
208 else
209 echo "Default SoundSets directory already exists. Skipping..."
213 if test -z "#LITE#" ; then
214 FILES=`(cd $GLOBALDIR; ls menu menu.* plmenu plmenu.?? wmmacros)`
215 for i in $FILES; do
216 # xx herbert
217 if [ -f "$GSDIR/Library/WindowMaker/$i" -a -z "$BATCH" ]; then
218 # /xx herbert
219 echo "The file \"$i\" already exists in $GSDIR/Library/WindowMaker"
220 echo "Do you wish to replace it? <y/n/a> [n] $all"
221 if [ "$all" != "a" ]; then
222 read foo
223 if [ "$foo" = "a" -o "$foo" = "A" ]; then
224 all="a"
227 if [ "$foo" = "y" -o "$foo" = "Y" -o "$foo" = "a" ]; then
228 copy $GLOBALDIR/$i $GSDIR/Library/WindowMaker/$i
230 else
231 copy $GLOBALDIR/$i $GSDIR/Library/WindowMaker/$i
233 done
236 cp $GLOBALDIR/README.themes $GSDIR/Library/WindowMaker
237 cp $GLOBALDIR/README $GSDIR/Library/WindowMaker
238 # xx herbert
239 if test -n "$BATCH"; then
240 test -f ~$GSDIR/Library/WindowMaker/autostart || \
241 cp $GLOBALDIR/autostart.sh $GSDIR/Library/WindowMaker/autostart
242 chmod +rx $GSDIR/Library/WindowMaker/autostart
243 test -f ~$GSDIR/Library/WindowMaker/exitscript || \
244 cp $GLOBALDIR/exitscript.sh $GSDIR/Library/WindowMaker/exitscript
245 chmod +rx $GSDIR/Library/WindowMaker/exitscript
246 else
247 cp -i $GLOBALDIR/autostart.sh $GSDIR/Library/WindowMaker/autostart
248 chmod +rx $GSDIR/Library/WindowMaker/autostart
249 cp -i $GLOBALDIR/exitscript.sh $GSDIR/Library/WindowMaker/exitscript
250 chmod +rx $GSDIR/Library/WindowMaker/exitscript
252 # /xx herbert
254 # xx herbert
255 if test -n "$BATCH" ; then
256 echo "Installation Finished"
257 exit 0
259 # /xx herbert
263 #######################
265 DATE=`date +%m%d%H%M`
267 show_end_message() {
269 echo
270 echo "Installation Finished"
271 echo
272 if test -z "#LITE#" ; then
273 echo "There are menus in 2 different file formats. The plain text format and"
274 echo "the property list format. The plain text format is more flexible, but"
275 echo "the menu in the property list format can be edited graphically. The"
276 echo "menu that will be used by default is the plain text. Read"
277 echo "$GSDIR/Library/WindowMaker/README for information on how to change it."
278 else
279 echo "Your copy of Window Maker is configured especially for KDE."
280 echo "Window Maker application menus are not available."
284 wmaker_found=1
285 for xinit in .xinitrc .Xclients .xsession; do
286 test ! -f "$HOME/$xinit" && continue
287 test -z "`grep wmaker $HOME/$xinit`"
288 [ $? -eq 0 ] && wmaker_found=0
289 done
290 [ $wmaker_found -eq 1 ] && show_end_message && exit 0
293 trap "show_end_message;exit" 2
295 echo
296 echo "Now the .xinitrc, .Xclients or .xsession script must be updated so that"
297 echo "it calls wmaker when you start an X session."
298 echo "Type the name of the file that must be changed (normally .xinitrc)."
299 echo "If the file already exists, it will be backed up with a .old.$DATE extension"
300 echo "If you want to edit it by hand, hit <Control>-C now."
301 read file
303 if test "x$file" = "x"; then
304 echo "Using .xinitrc as a default value"
305 file=.xinitrc
308 if [ -f $USERDIR/$file ]; then
309 mv $USERDIR/$file $USERDIR/$file.old.$DATE
312 make_script $USERDIR/$file
314 show_end_message