fixed bug in builtin xpm loader
[wmaker-crm.git] / util / wmaker.inst.in
blob24e9beaa8f0e0baa47ebdba77f36ebc8d323f061
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
15 LOCALE=$LANG
16 if [ -z "$LOCALE" ]; then
17 LOCALE=$LC_ALL
20 # directory where system wide configuration is stored
21 GLOBALDIR="#pkgdatadir#"
22 GLOBALDEFDIR="#sysconfdir#"
24 USERDIR=$HOME
26 VERSION="#version#"
28 BINDIR="#bindir#"
30 make_dir() {
31 mkdir $1
32 chmod +rwx $1
35 make_script() {
36 ISCRIPT=$1
38 cat << EOF >> $ISCRIPT
39 # Window Maker default X session startup script
41 PATH="\$PATH:$BINDIR"
43 # If you login from xdm, uncomment this to make error messages appear
44 # in the console window.
46 # tail -f $HOME/.xsession-errors > /dev/console &
48 exec wmaker
50 EOF
51 chmod +rx $ISCRIPT
56 # Copy files considering special cases
58 copy() {
59 source=$1
60 target=$2
61 file=`basename $source`
62 rm -f $target
63 if [ "$file" = "WindowMaker" ]; then
64 sed -e "s|~/GNUstep|$GSDIR|g" $source > $target
65 elif [ "$file" = "WMRootMenu" ]; then
66 if [ "$LOCALE" ]; then
67 if [ -f $GLOBALDIR/plmenu.${LOCALE%_*} ]; then
68 cp $GLOBALDIR/plmenu.${LOCALE%_*} $GSDIR/Defaults/WMRootMenu
69 else
70 cp $GLOBALDIR/plmenu $GSDIR/Defaults/WMRootMenu
72 else
73 cp $GLOBALDIR/plmenu $GSDIR/Defaults/WMRootMenu
75 else
76 if test "x$GNUSTEP_USER_ROOT" = "x"; then
77 sed -e "s:#wmdatadir#:$GLOBALDIR:g" \
78 $source > $target
79 else
80 sed -e "s|\$HOME/GNUstep|$GSDIR|g" \
81 -e "s:#wmdatadir#:$GLOBALDIR:g" \
82 $source > $target
89 echo "Installing WindowMaker $VERSION for current user..."
92 if [ ! -d $GLOBALDIR ]; then
93 echo "Could not find global data files"
94 echo "Make sure you have installed Window Maker correctly"
95 exit 1
98 if [ ! -d $GLOBALDEFDIR ]; then
99 echo "Could not find global configurations files"
100 echo "Make sure you have installed Window Maker correctly"
101 exit 1
104 if [ ! -d "$USERDIR" ]; then
105 echo "Could not find user directory $USERDIR"
106 exit 1
110 if test "x$GNUSTEP_USER_ROOT" = "x"; then
111 cd $USERDIR
112 GSDIR=$USERDIR/GNUstep
113 if [ ! -d $GSDIR ]; then
114 echo "Creating $GSDIR user directory"
115 make_dir $GSDIR
117 else
118 GSDIR=$GNUSTEP_USER_ROOT
119 if [ ! -d $GSDIR ]; then
120 echo "Directory specified in GNUSTEP_USER_ROOT environment variable does not exist"
121 exit 1
123 cd $GSDIR
124 cd ..
128 if [ ! -d "$GSDIR/.AppInfo" ]; then
129 make_dir $GSDIR/.AppInfo
132 if [ ! -d "$GSDIR/Defaults" ]; then
133 make_dir $GSDIR/Defaults
136 echo "Copying defaults database..."
138 FILES=`(cd $GLOBALDEFDIR;ls -d *)`
139 all=""
140 for i in $FILES; do
141 if [ ! -d $GLOBALDEFDIR/$i ]; then
142 if [ -f $GSDIR/Defaults/$i -a -z "$BATCH" ]; then
143 echo "The configuration file \"$i\" already exists in your defaults database."
144 echo "Do you wish to replace it? <y/n/a> [n] $all"
145 if [ "$all" != "a" ]; then
146 read foo
147 if [ "$foo" = "a" -o "$foo" = "A" ]; then
148 all="a"
151 if [ "$foo" = "y" -o "$foo" = "Y" -o "$all" = "a" ]; then
152 copy $GLOBALDEFDIR/$i $GSDIR/Defaults/$i
154 else
155 copy $GLOBALDEFDIR/$i $GSDIR/Defaults/$i
158 done
161 if [ ! -d "$GSDIR/Library/Icons/" ]; then
162 echo "Creating icon library directory $GSDIR/Library/Icons"
163 if [ ! -d $GSDIR/Library ]; then
164 make_dir $GSDIR/Library
166 make_dir $GSDIR/Library/Icons
170 if [ ! -d "$GSDIR/Library/WindowMaker/" ]; then
171 echo "Creating WindowMaker data library directory $GSDIR/Library/WindowMaker"
172 if [ ! -d $GSDIR/Library ]; then
173 make_dir $GSDIR/Library
175 make_dir $GSDIR/Library/WindowMaker
178 if [ ! -d "$GSDIR/Library/WindowMaker/Styles" ]; then
179 echo "Creating style library $GSDIR/Library/WindowMaker/Styles"
180 make_dir $GSDIR/Library/WindowMaker/Styles
184 if [ ! -d "$GSDIR/Library/WindowMaker/Themes" ]; then
185 echo "Creating theme library $GSDIR/Library/WindowMaker/Themes"
186 make_dir $GSDIR/Library/WindowMaker/Themes
191 if [ ! -d "$GSDIR/Library/WindowMaker/Backgrounds" ]; then
192 echo "Creating bg image library $GSDIR/Library/WindowMaker/Backgrounds"
193 make_dir $GSDIR/Library/WindowMaker/Backgrounds
194 else
195 echo "Default Backgrounds directory already exists. Skipping..."
199 if [ ! -d "$GSDIR/Library/WindowMaker/IconSets" ]; then
200 echo "Creating icon setup library $GSDIR/Library/WindowMaker/IconSets"
201 make_dir $GSDIR/Library/WindowMaker/IconSets
202 else
203 echo "Default IconSets directory already exists. Skipping..."
207 if [ ! -d "$GSDIR/Library/WindowMaker/Pixmaps" ]; then
208 echo "Creating pixmap library $GSDIR/Library/WindowMaker/Pixmaps"
209 make_dir $GSDIR/Library/WindowMaker/Pixmaps
210 else
211 echo "Default Pixmaps directory already exists. Skipping..."
215 if [ ! -d "$GSDIR/Library/WindowMaker/Sounds" ]; then
216 echo "Creating sound library $GSDIR/Library/WindowMaker/Sounds"
217 make_dir $GSDIR/Library/WindowMaker/Sounds
218 else
219 echo "Default Sounds directory already exists. Skipping..."
223 if [ ! -d "$GSDIR/Library/WindowMaker/SoundSets" ]; then
224 echo "Creating sound set library $GSDIR/Library/WindowMaker/SoundSets"
225 make_dir $GSDIR/Library/WindowMaker/SoundSets
226 else
227 echo "Default SoundSets directory already exists. Skipping..."
231 if test -z "#LITE#" ; then
232 FILES=`(cd $GLOBALDIR; ls menu menu.* plmenu plmenu.?? wmmacros)`
233 for i in $FILES; do
234 # xx herbert
235 if [ -f "$GSDIR/Library/WindowMaker/$i" -a -z "$BATCH" ]; then
236 # /xx herbert
237 echo "The file \"$i\" already exists in $GSDIR/Library/WindowMaker"
238 echo "Do you wish to replace it? <y/n/a> [n] $all"
239 if [ "$all" != "a" ]; then
240 read foo
241 if [ "$foo" = "a" -o "$foo" = "A" ]; then
242 all="a"
245 if [ "$foo" = "y" -o "$foo" = "Y" -o "$foo" = "a" ]; then
246 copy $GLOBALDIR/$i $GSDIR/Library/WindowMaker/$i
248 else
249 copy $GLOBALDIR/$i $GSDIR/Library/WindowMaker/$i
251 done
254 cp $GLOBALDIR/README.themes $GSDIR/Library/WindowMaker
255 cp $GLOBALDIR/README $GSDIR/Library/WindowMaker
257 test -f ~$GSDIR/Library/WindowMaker/autostart || \
258 cp $GLOBALDIR/autostart.sh $GSDIR/Library/WindowMaker/autostart
259 chmod +rx $GSDIR/Library/WindowMaker/autostart
261 test -f ~$GSDIR/Library/WindowMaker/exitscript || \
262 cp $GLOBALDIR/exitscript.sh $GSDIR/Library/WindowMaker/exitscript
263 chmod +rx $GSDIR/Library/WindowMaker/exitscript
265 # xx herbert
266 if test -n "$BATCH" ; then
267 echo "Installation Finished"
268 exit 0
270 # /xx herbert
274 #######################
276 DATE=`date +%b%d.%T`
278 show_end_message() {
280 echo
281 echo "Installation Finished"
282 echo
283 if test -z "#LITE#" ; then
284 echo "There are menus in 2 different file formats. The plain text format and"
285 echo "the property list format. The plain text format is more flexible, but"
286 echo "the menu in the property list format can be edited graphically. The"
287 echo "menu that will be used by default is the property list one. Read"
288 echo "$GSDIR/Library/WindowMaker/README for information on how to change it."
289 else
290 echo "Your copy of Window Maker is configured especially for KDE."
291 echo "Window Maker application menus are not available."
295 wmaker_found=0
296 for xinit in .xinitrc .Xclients .xsession; do
297 test ! -f "$HOME/$xinit" && continue
298 res="`grep wmaker $HOME/$xinit`"
299 if test "x$res" != x; then
300 wmaker_found=1
301 break
303 done
304 if test $wmaker_found = 1; then
305 echo "Found Window Maker to already be your default window manager."
306 show_end_message
307 exit 0
311 trap "show_end_message;exit" 2
313 echo
314 echo "Now the .xinitrc, .Xclients or .xsession script must be updated so that"
315 echo "it calls wmaker when you start an X session."
316 echo "Type the name of the file that must be changed (normally .xinitrc)."
317 echo "If the file already exists, it will be backed up with a .old.$DATE "
318 echo "extension"
319 echo "If you want to edit it by hand, hit <Control>-C now."
320 read file
322 if test "x$file" = "x"; then
323 echo "Using .xinitrc as a default value"
324 file=.xinitrc
327 if [ -f $USERDIR/$file ]; then
328 mv $USERDIR/$file $USERDIR/$file.old.$DATE
331 make_script $USERDIR/$file
333 show_end_message