applied patch to rename .AppInfo directory
[wmaker-crm.git] / util / wmaker.inst.in
blob2c2c0fdc1962fef5cba125491baa414e0f832648
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 # name of menu file we install (menu, plmenu)
15 inst_menu=""
17 LOCALE=$LANG
18 if [ -z "$LOCALE" ]; then
19 LOCALE=$LC_ALL
22 # directory where system wide configuration is stored
23 GLOBALDIR="#pkgdatadir#"
24 GLOBALDEFDIR="#sysconfdir#"
26 USERDIR=$HOME
28 VERSION="#version#"
30 BINDIR="#bindir#"
32 make_dir() {
33 mkdir $1
34 chmod +rwx $1
37 make_script() {
38 ISCRIPT=$1
40 cat << EOF >> $ISCRIPT
41 # Window Maker default X session startup script
43 PATH="\$PATH:$BINDIR"
45 # If you login from xdm, uncomment this to make error messages appear
46 # in the console window.
48 # tail -f $HOME/.xsession-errors > /dev/console &
50 exec wmaker
52 EOF
53 chmod +rx $ISCRIPT
58 # Copy files considering special cases
60 copy() {
61 source=$1
62 target=$2
63 file=`basename $source`
64 rm -f $target
65 if [ "$file" = "WindowMaker" ]; then
66 sed -e "s|~/GNUstep|$GSDIR|g" $source > $target
67 elif [ "$file" = "WMRootMenu" ]; then
68 if [ "$LOCALE" ]; then
69 if [ -f $GLOBALDIR/plmenu.$LOCALE ]; then
70 source=$GLOBALDIR/plmenu.$LOCALE
71 elif [ -f $GLOBALDIR/plmenu.${LOCALE%.*} ]; then
72 source=$GLOBALDIR/plmenu.${LOCALE%.*}
73 elif [ -f $GLOBALDIR/plmenu.${LOCALE%_*} ]; then
74 source=$GLOBALDIR/plmenu.${LOCALE%_*}
75 elif [ -f $GLOBALDIR/menu.${LOCALE%_*} ]; then
76 source=$GLOBALDIR/menu.${LOCALE%_*}
77 else
78 source=$GLOBALDIR/plmenu
80 else
81 source=$GLOBALDIR/plmenu
83 sed -e "s:#wmdatadir#:$GLOBALDIR:g" \
84 $source > $GSDIR/Defaults/WMRootMenu
85 else
86 if test "x$GNUSTEP_USER_ROOT" = "x"; then
87 sed -e "s:#wmdatadir#:$GLOBALDIR:g" \
88 $source > $target
89 else
90 sed -e "s|\$HOME/GNUstep|$GSDIR|g" \
91 -e "s:#wmdatadir#:$GLOBALDIR:g" \
92 $source > $target
99 echo "Installing WindowMaker $VERSION for current user..."
102 if [ ! -d $GLOBALDIR ]; then
103 echo "Could not find global data files"
104 echo "Make sure you have installed Window Maker correctly"
105 exit 1
108 if [ ! -d $GLOBALDEFDIR ]; then
109 echo "Could not find global configurations files"
110 echo "Make sure you have installed Window Maker correctly"
111 exit 1
114 if [ ! -d "$USERDIR" ]; then
115 echo "Could not find user directory $USERDIR"
116 exit 1
120 if test "x$GNUSTEP_USER_ROOT" = "x"; then
121 cd $USERDIR
122 GSDIR=$USERDIR/GNUstep
123 if [ ! -d $GSDIR ]; then
124 echo "Creating $GSDIR user directory"
125 make_dir $GSDIR
127 else
128 GSDIR=$GNUSTEP_USER_ROOT
129 if [ ! -d $GSDIR ]; then
130 echo "Directory specified in GNUSTEP_USER_ROOT environment variable does not exist"
131 exit 1
133 cd $GSDIR
134 cd ..
138 if [ ! -d "$GSDIR/Library/WindowMaker/CachedPixmaps" ]; then
139 make_dir $GSDIR/WindowMaker/CachedPixmaps
142 if [ ! -d "$GSDIR/Library/WindowMaker/WPrefs" ]; then
143 make_dir $GSDIR/WindowMaker/WPrefs
146 if [ ! -d "$GSDIR/Defaults" ]; then
147 make_dir $GSDIR/Defaults
150 echo "Copying defaults database..."
152 FILES=`(cd $GLOBALDEFDIR;ls -d *)`
153 all=""
154 for i in $FILES; do
155 if [ ! -d $GLOBALDEFDIR/$i ]; then
156 if [ -f $GSDIR/Defaults/$i -a -z "$BATCH" ]; then
157 echo "The configuration file \"$i\" already exists in your defaults database."
158 echo "Do you wish to replace it? <y/n/a> [n] $all"
159 if [ "$all" != "a" ]; then
160 read foo
161 if [ "$foo" = "a" -o "$foo" = "A" ]; then
162 all="a"
165 if [ "$foo" = "y" -o "$foo" = "Y" -o "$all" = "a" ]; then
166 copy $GLOBALDEFDIR/$i $GSDIR/Defaults/$i
168 else
169 copy $GLOBALDEFDIR/$i $GSDIR/Defaults/$i
172 done
175 if [ ! -d "$GSDIR/Library/Icons/" ]; then
176 echo "Creating icon library directory $GSDIR/Library/Icons"
177 if [ ! -d $GSDIR/Library ]; then
178 make_dir $GSDIR/Library
180 make_dir $GSDIR/Library/Icons
184 if [ ! -d "$GSDIR/Library/WindowMaker/" ]; then
185 echo "Creating WindowMaker data library directory $GSDIR/Library/WindowMaker"
186 if [ ! -d $GSDIR/Library ]; then
187 make_dir $GSDIR/Library
189 make_dir $GSDIR/Library/WindowMaker
192 if [ ! -d "$GSDIR/Library/WindowMaker/Styles" ]; then
193 echo "Creating style library $GSDIR/Library/WindowMaker/Styles"
194 make_dir $GSDIR/Library/WindowMaker/Styles
198 if [ ! -d "$GSDIR/Library/WindowMaker/Themes" ]; then
199 echo "Creating theme library $GSDIR/Library/WindowMaker/Themes"
200 make_dir $GSDIR/Library/WindowMaker/Themes
205 if [ ! -d "$GSDIR/Library/WindowMaker/Backgrounds" ]; then
206 echo "Creating bg image library $GSDIR/Library/WindowMaker/Backgrounds"
207 make_dir $GSDIR/Library/WindowMaker/Backgrounds
208 else
209 echo "Default Backgrounds directory already exists. Skipping..."
213 if [ ! -d "$GSDIR/Library/WindowMaker/IconSets" ]; then
214 echo "Creating icon setup library $GSDIR/Library/WindowMaker/IconSets"
215 make_dir $GSDIR/Library/WindowMaker/IconSets
216 else
217 echo "Default IconSets directory already exists. Skipping..."
221 if [ ! -d "$GSDIR/Library/WindowMaker/Pixmaps" ]; then
222 echo "Creating pixmap library $GSDIR/Library/WindowMaker/Pixmaps"
223 make_dir $GSDIR/Library/WindowMaker/Pixmaps
224 else
225 echo "Default Pixmaps directory already exists. Skipping..."
229 if [ ! -d "$GSDIR/Library/WindowMaker/Sounds" ]; then
230 echo "Creating sound library $GSDIR/Library/WindowMaker/Sounds"
231 make_dir $GSDIR/Library/WindowMaker/Sounds
232 else
233 echo "Default Sounds directory already exists. Skipping..."
237 if [ ! -d "$GSDIR/Library/WindowMaker/SoundSets" ]; then
238 echo "Creating sound set library $GSDIR/Library/WindowMaker/SoundSets"
239 make_dir $GSDIR/Library/WindowMaker/SoundSets
240 else
241 echo "Default SoundSets directory already exists. Skipping..."
245 if test -z "#LITE#" ; then
246 FILES=`(cd $GLOBALDIR; ls menu menu.* plmenu plmenu.?? wmmacros)`
247 for i in $FILES; do
248 # xx herbert
249 if [ -f "$GSDIR/Library/WindowMaker/$i" -a -z "$BATCH" ]; then
250 # /xx herbert
251 echo "The file \"$i\" already exists in $GSDIR/Library/WindowMaker"
252 echo "Do you wish to replace it? <y/n/a> [n] $all"
253 if [ "$all" != "a" ]; then
254 read foo
255 if [ "$foo" = "a" -o "$foo" = "A" ]; then
256 all="a"
259 if [ "$foo" = "y" -o "$foo" = "Y" -o "$foo" = "a" ]; then
260 copy $GLOBALDIR/$i $GSDIR/Library/WindowMaker/$i
262 else
263 copy $GLOBALDIR/$i $GSDIR/Library/WindowMaker/$i
265 done
268 cp $GLOBALDIR/README.themes $GSDIR/Library/WindowMaker
269 cp $GLOBALDIR/README $GSDIR/Library/WindowMaker
271 test -f ~$GSDIR/Library/WindowMaker/autostart || \
272 cp $GLOBALDIR/autostart.sh $GSDIR/Library/WindowMaker/autostart
273 chmod +rx $GSDIR/Library/WindowMaker/autostart
275 test -f ~$GSDIR/Library/WindowMaker/exitscript || \
276 cp $GLOBALDIR/exitscript.sh $GSDIR/Library/WindowMaker/exitscript
277 chmod +rx $GSDIR/Library/WindowMaker/exitscript
279 # xx herbert
280 if test -n "$BATCH" ; then
281 echo "Installation Finished"
282 exit 0
284 # /xx herbert
288 #######################
290 DATE=`date +%b%d.%T`
292 show_end_message() {
294 echo
295 echo "Installation Finished"
296 echo
297 if test -z "#LITE#" ; then
298 echo "There are menus in 2 different file formats. The plain text format and"
299 echo "the property list format. The plain text format is more flexible, but"
300 echo "the menu in the property list format can be edited graphically. The"
301 echo "menu that will be used by default is the property list one. Read"
302 echo " $GSDIR/Library/WindowMaker/README"
303 echo "for information on how to change it."
304 if [ "${inst_menu%.*}" = "menu" ]; then
305 echo "However, since you have locale set to $LOCALE and plmenu for such locale"
306 echo "was not found, your WMRootMenu contains path to text formated menu:"
307 echo " $GSDIR/Library/WindowMaker/$inst_menu"
309 else
310 echo "Your copy of Window Maker is configured especially for KDE."
311 echo "Window Maker application menus are not available."
315 wmaker_found=0
316 for xinit in .xinitrc .Xclients .xsession; do
317 test ! -f "$HOME/$xinit" && continue
318 res="`grep wmaker $HOME/$xinit`"
319 if test "x$res" != x; then
320 wmaker_found=1
321 break
323 done
324 if test $wmaker_found = 1; then
325 echo "Found Window Maker to already be your default window manager."
326 show_end_message
327 exit 0
331 trap "show_end_message;exit" 2
333 echo
334 echo "Now the .xinitrc, .Xclients or .xsession script must be updated so that"
335 echo "it calls wmaker when you start an X session."
336 echo "Type the name of the file that must be changed (normally .xinitrc)."
337 echo "If the file already exists, it will be backed up with a .old.$DATE "
338 echo "extension"
339 echo "If you want to edit it by hand, hit <Control>-C now."
340 read file
342 if test "x$file" = "x"; then
343 echo "Using .xinitrc as a default value"
344 file=.xinitrc
347 if [ -f $USERDIR/$file ]; then
348 mv $USERDIR/$file $USERDIR/$file.old.$DATE
351 make_script $USERDIR/$file
353 show_end_message