Files
wmaker/util/wmaker.inst.in
T

317 lines
7.5 KiB
Bash
Raw Normal View History

1998-09-29 22:36:29 +00:00
#!/bin/sh
#
1998-10-21 14:43:47 +00:00
# Install Window Maker for the current user
1998-09-29 22:36:29 +00:00
#
1999-01-25 19:06:50 +00:00
# xx herbert
2001-02-08 22:43:00 +00:00
if test "x$1" = "x--batch" ; then
1999-01-25 19:06:50 +00:00
BATCH="1"
else
BATCH=""
fi
# /xx herbert
2001-02-08 22:43:00 +00:00
# name of menu file we install (menu, plmenu)
inst_menu=""
2001-01-06 22:38:07 +00:00
2010-10-08 16:14:43 +04:00
LOCALE="${LC_ALL-${LC_MESSAGES-$LANG}}"
2001-01-06 22:38:07 +00:00
1998-09-29 22:36:29 +00:00
# directory where system wide configuration is stored
GLOBALDIR="#pkgdatadir#"
GLOBALDEFDIR="#sysconfdir#"
1998-09-29 22:36:29 +00:00
2010-10-08 16:14:44 +04:00
USERDIR="$HOME"
1998-09-29 22:36:29 +00:00
VERSION="#version#"
BINDIR="#bindir#"
1998-11-23 11:32:19 +00:00
make_dir() {
2010-10-08 16:14:44 +04:00
mkdir "$1"
chmod +rwx "$1"
1998-11-23 11:32:19 +00:00
}
1998-09-29 22:36:29 +00:00
make_script() {
2010-10-08 16:14:44 +04:00
ISCRIPT="$1"
1998-10-21 14:43:47 +00:00
2010-10-08 16:14:44 +04:00
cat << EOF >> "$ISCRIPT"
1998-10-21 14:43:47 +00:00
# Window Maker default X session startup script
PATH="\$PATH:$BINDIR"
# If you login from xdm, uncomment this to make error messages appear
# in the console window.
#
2010-10-08 16:14:44 +04:00
# tail -f "$HOME"/.xsession-errors > /dev/console &
1998-10-21 14:43:47 +00:00
exec wmaker
EOF
2010-10-08 16:14:44 +04:00
chmod +rx "$ISCRIPT"
1998-09-29 22:36:29 +00:00
}
#
# Copy files considering special cases
#
copy() {
2010-10-08 16:14:44 +04:00
source="$1"
target="$2"
file="$(basename "$source")"
rm -f "$target"
if [ "$file" = "WindowMaker" ]; then
2010-10-08 16:14:44 +04:00
sed -e "s|~/GNUstep|$GSDIR|g" "$source" > "$target"
1998-09-29 22:36:29 +00:00
else
if test "x$GNUSTEP_USER_ROOT" = "x"; then
1999-01-11 12:28:12 +00:00
sed -e "s:#wmdatadir#:$GLOBALDIR:g" \
2010-10-08 16:14:44 +04:00
"$source" > "$target"
1998-09-29 22:36:29 +00:00
else
sed -e "s|\$HOME/GNUstep|$GSDIR|g" \
1999-01-11 12:28:12 +00:00
-e "s:#wmdatadir#:$GLOBALDIR:g" \
2010-10-08 16:14:44 +04:00
"$source" > "$target"
1998-09-29 22:36:29 +00:00
fi
fi
}
#
# Generate WMRootmenu
#
GenerateMenu() {
wmgenmenu > $GSDIR/Defaults/WMRootMenu
}
1998-09-29 22:36:29 +00:00
echo "Installing WindowMaker $VERSION for current user..."
2010-10-08 16:14:44 +04:00
if [ ! -d "$GLOBALDIR" ]; then
echo "Could not find global data files"
echo "Make sure you have installed Window Maker correctly"
exit 1
fi
2010-10-08 16:14:44 +04:00
if [ ! -d "$GLOBALDEFDIR" ]; then
1998-09-29 22:36:29 +00:00
echo "Could not find global configurations files"
1999-01-11 12:28:12 +00:00
echo "Make sure you have installed Window Maker correctly"
1998-09-29 22:36:29 +00:00
exit 1
fi
if [ ! -d "$USERDIR" ]; then
echo "Could not find user directory $USERDIR"
exit 1
fi
if test "x$GNUSTEP_USER_ROOT" = "x"; then
2010-10-08 16:14:44 +04:00
cd "$USERDIR"
GSDIR="$USERDIR/GNUstep"
if [ ! -d "$GSDIR" ]; then
1998-09-29 22:36:29 +00:00
echo "Creating $GSDIR user directory"
2010-10-08 16:14:44 +04:00
make_dir "$GSDIR"
1998-09-29 22:36:29 +00:00
fi
else
2010-10-08 16:14:44 +04:00
GSDIR="$GNUSTEP_USER_ROOT"
if [ ! -d "$GSDIR" ]; then
1998-09-29 22:36:29 +00:00
echo "Directory specified in GNUSTEP_USER_ROOT environment variable does not exist"
exit 1
fi
2010-10-08 16:14:44 +04:00
cd "$GSDIR"
1998-09-29 22:36:29 +00:00
cd ..
fi
if [ ! -d "$GSDIR/Defaults" ]; then
2010-10-08 16:14:44 +04:00
make_dir "$GSDIR/Defaults"
1998-09-29 22:36:29 +00:00
fi
echo "Copying defaults database..."
2010-10-08 16:14:44 +04:00
FILES="$(cd "$GLOBALDEFDIR" && ls -d *)"
1998-09-29 22:36:29 +00:00
all=""
for i in $FILES; do
2010-10-08 16:14:44 +04:00
if [ ! -d "$GLOBALDEFDIR/$i" ]; then
if [ -f "$GSDIR/Defaults/$i" -a -z "$BATCH" ]; then
1999-04-10 19:32:34 +00:00
echo "The configuration file \"$i\" already exists in your defaults database."
echo "Do you wish to replace it? <y/n/a> [n] $all"
if [ "$all" != "a" ]; then
read foo
if [ "$foo" = "a" -o "$foo" = "A" ]; then
all="a"
fi
1998-09-29 22:36:29 +00:00
fi
1999-04-10 19:32:34 +00:00
if [ "$foo" = "y" -o "$foo" = "Y" -o "$all" = "a" ]; then
2010-10-08 16:14:44 +04:00
copy "$GLOBALDEFDIR/$i" "$GSDIR/Defaults/$i"
1999-04-10 19:32:34 +00:00
fi
else
2010-10-08 16:14:44 +04:00
copy "$GLOBALDEFDIR/$i" "$GSDIR/Defaults/$i"
1998-09-29 22:36:29 +00:00
fi
fi
done
GenerateMenu
1998-09-29 22:36:29 +00:00
if [ ! -d "$GSDIR/Library/Icons/" ]; then
echo "Creating icon library directory $GSDIR/Library/Icons"
2010-10-08 16:14:44 +04:00
if [ ! -d "$GSDIR/Library" ]; then
make_dir "$GSDIR/Library"
1998-09-29 22:36:29 +00:00
fi
2010-10-08 16:14:44 +04:00
make_dir "$GSDIR/Library/Icons"
1998-09-29 22:36:29 +00:00
fi
if [ ! -d "$GSDIR/Library/WindowMaker/" ]; then
echo "Creating WindowMaker data library directory $GSDIR/Library/WindowMaker"
2010-10-08 16:14:44 +04:00
if [ ! -d "$GSDIR/Library" ]; then
make_dir "$GSDIR/Library"
1998-09-29 22:36:29 +00:00
fi
2010-10-08 16:14:44 +04:00
make_dir "$GSDIR/Library/WindowMaker"
1998-09-29 22:36:29 +00:00
fi
if [ ! -d "$GSDIR/Library/WindowMaker/Styles" ]; then
echo "Creating style library $GSDIR/Library/WindowMaker/Styles"
2010-10-08 16:14:44 +04:00
make_dir "$GSDIR/Library/WindowMaker/Styles"
1998-09-29 22:36:29 +00:00
fi
if [ ! -d "$GSDIR/Library/WindowMaker/Themes" ]; then
echo "Creating theme library $GSDIR/Library/WindowMaker/Themes"
2010-10-08 16:14:44 +04:00
make_dir "$GSDIR/Library/WindowMaker/Themes"
1998-09-29 22:36:29 +00:00
fi
if [ ! -d "$GSDIR/Library/WindowMaker/Backgrounds" ]; then
echo "Creating bg image library $GSDIR/Library/WindowMaker/Backgrounds"
2010-10-08 16:14:44 +04:00
make_dir "$GSDIR/Library/WindowMaker/Backgrounds"
1998-09-29 22:36:29 +00:00
else
echo "Default Backgrounds directory already exists. Skipping..."
fi
if [ ! -d "$GSDIR/Library/WindowMaker/IconSets" ]; then
echo "Creating icon setup library $GSDIR/Library/WindowMaker/IconSets"
2010-10-08 16:14:44 +04:00
make_dir "$GSDIR/Library/WindowMaker/IconSets"
1998-09-29 22:36:29 +00:00
else
echo "Default IconSets directory already exists. Skipping..."
fi
if [ ! -d "$GSDIR/Library/WindowMaker/Pixmaps" ]; then
echo "Creating pixmap library $GSDIR/Library/WindowMaker/Pixmaps"
2010-10-08 16:14:44 +04:00
make_dir "$GSDIR/Library/WindowMaker/Pixmaps"
1998-09-29 22:36:29 +00:00
else
echo "Default Pixmaps directory already exists. Skipping..."
fi
if [ ! -d "$GSDIR/Library/WindowMaker/CachedPixmaps" ]; then
2010-10-08 16:14:44 +04:00
make_dir "$GSDIR/Library/WindowMaker/CachedPixmaps"
fi
if [ ! -d "$GSDIR/Library/WindowMaker/WPrefs" ]; then
2010-10-08 16:14:44 +04:00
make_dir "$GSDIR/Library/WindowMaker/WPrefs"
fi
1999-01-11 12:28:12 +00:00
if test -z "#LITE#" ; then
2010-10-08 16:14:44 +04:00
FILES="$(cd "$GLOBALDIR" && ls menu menu.* plmenu plmenu.?? wmmacros)"
1998-09-29 22:36:29 +00:00
for i in $FILES; do
1999-01-25 19:06:50 +00:00
# xx herbert
if [ -f "$GSDIR/Library/WindowMaker/$i" -a -z "$BATCH" ]; then
# /xx herbert
1998-09-29 22:36:29 +00:00
echo "The file \"$i\" already exists in $GSDIR/Library/WindowMaker"
echo "Do you wish to replace it? <y/n/a> [n] $all"
if [ "$all" != "a" ]; then
read foo
if [ "$foo" = "a" -o "$foo" = "A" ]; then
all="a"
fi
fi
if [ "$foo" = "y" -o "$foo" = "Y" -o "$foo" = "a" ]; then
2010-10-08 16:14:44 +04:00
copy "$GLOBALDIR/$i" "$GSDIR/Library/WindowMaker/$i"
1998-09-29 22:36:29 +00:00
fi
else
2010-10-08 16:14:44 +04:00
copy "$GLOBALDIR/$i" "$GSDIR/Library/WindowMaker/$i"
1998-09-29 22:36:29 +00:00
fi
done
1999-01-06 15:22:33 +00:00
fi
1998-09-29 22:36:29 +00:00
2010-10-08 16:14:44 +04:00
cp "$GLOBALDIR/README.themes" "$GSDIR/Library/WindowMaker"
cp "$GLOBALDIR/README" "$GSDIR/Library/WindowMaker"
1999-03-09 14:58:01 +00:00
2010-10-08 16:14:44 +04:00
test -f "$GSDIR/Library/WindowMaker/autostart" || \
cp "$GLOBALDIR/autostart.sh" "$GSDIR/Library/WindowMaker/autostart"
chmod +rx "$GSDIR/Library/WindowMaker/autostart"
1999-03-09 14:58:01 +00:00
2010-10-08 16:14:44 +04:00
test -f "$GSDIR/Library/WindowMaker/exitscript" || \
cp "$GLOBALDIR/exitscript.sh" "$GSDIR/Library/WindowMaker/exitscript"
chmod +rx "$GSDIR/Library/WindowMaker/exitscript"
1999-01-25 19:06:50 +00:00
# xx herbert
if test -n "$BATCH" ; then
echo "Installation Finished"
exit 0
fi
# /xx herbert
1998-09-29 22:36:29 +00:00
#
#######################
2010-10-08 16:14:44 +04:00
DATE="$(date +%b%d.%T)"
1998-09-29 22:36:29 +00:00
1998-10-21 14:43:47 +00:00
show_end_message() {
echo
echo "Installation Finished"
echo
echo "There are menus in 2 different file formats. The plain text format and"
echo "the property list format. The plain text format is more flexible, but"
echo "the menu in the property list format can be edited graphically. The"
echo "menu that will be used by default is the property list one. Read"
echo " $GSDIR/Library/WindowMaker/README"
echo "for information on how to change it."
if [ "${inst_menu%.*}" = "menu" ]; then
echo "However, since you have locale set to $LOCALE and plmenu for such locale"
echo "was not found, your WMRootMenu contains path to text formated menu:"
echo " $GSDIR/Library/WindowMaker/$inst_menu"
fi
1998-10-21 14:43:47 +00:00
}
1999-03-09 14:58:01 +00:00
wmaker_found=0
1999-01-25 19:06:50 +00:00
for xinit in .xinitrc .Xclients .xsession; do
test ! -f "$HOME/$xinit" && continue
2010-10-08 16:14:44 +04:00
res="$(grep wmaker "$HOME/$xinit")"
1999-03-09 14:58:01 +00:00
if test "x$res" != x; then
wmaker_found=1
break
fi
1999-01-25 19:06:50 +00:00
done
2010-10-08 16:14:44 +04:00
if test "$wmaker_found" = 1; then
echo "Found Window Maker to already be your default window manager."
1999-03-09 14:58:01 +00:00
show_end_message
exit 0
fi
1999-01-25 19:06:50 +00:00
1998-10-21 14:43:47 +00:00
trap "show_end_message;exit" 2
1998-09-29 22:36:29 +00:00
echo
echo "Now the .xinitrc, .Xclients or .xsession script must be updated so that"
echo "it calls wmaker when you start an X session."
echo "Type the name of the file that must be changed (normally .xinitrc)."
1999-03-09 14:58:01 +00:00
echo "If the file already exists, it will be backed up with a .old.$DATE "
echo "extension"
1998-10-21 14:43:47 +00:00
echo "If you want to edit it by hand, hit <Control>-C now."
1998-09-29 22:36:29 +00:00
read file
if test "x$file" = "x"; then
echo "Using .xinitrc as a default value"
file=.xinitrc
fi
2010-10-08 16:14:44 +04:00
if [ -f "$USERDIR/$file" ]; then
mv "$USERDIR/$file" "$USERDIR/$file.old.$DATE"
1998-09-29 22:36:29 +00:00
fi
2010-10-08 16:14:44 +04:00
make_script "$USERDIR/$file"
1998-09-29 22:36:29 +00:00
1998-10-21 14:43:47 +00:00
show_end_message