Use W_KeycodeToKeysym instead of XkbKeycodeToKeysym
[wmaker-crm.git] / util / wmaker.inst.in
blobcee8c0dc5af56b1250f91ef49f722ea0df6bfa4f
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="${LC_ALL-${LC_MESSAGES-$LANG}}"
19 # directory where system wide configuration is stored
20 GLOBALDIR="#pkgdatadir#"
21 GLOBALDEFDIR="#sysconfdir#"
23 USERDIR="$HOME"
25 VERSION="#version#"
27 BINDIR="#bindir#"
29 make_dir() {
30 mkdir "$1"
31 chmod +rwx "$1"
35 # Copy files considering special cases
37 copy() {
38 source="$1"
39 target="$2"
40 file="$(basename "$source")"
41 rm -f "$target"
42 if [ "$file" = "WindowMaker" ]; then
43 sed -e "s|~/GNUstep|$GSDIR|g" "$source" > "$target"
44 else
45 if test "x$WMAKER_USER_ROOT" != "x"; then
46 sed -e "s|\$HOME/GNUstep|$GSDIR|g" \
47 "$source" > "$target"
53 # Generate WMRootmenu
55 GenerateMenu() {
56 wmgenmenu > $GSDIR/Defaults/WMRootMenu
59 echo "Installing WindowMaker $VERSION for current user..."
62 if [ ! -d "$GLOBALDIR" ]; then
63 echo "Could not find global data files"
64 echo "Make sure you have installed Window Maker correctly"
65 exit 1
68 if [ ! -d "$GLOBALDEFDIR" ]; then
69 echo "Could not find global configurations files"
70 echo "Make sure you have installed Window Maker correctly"
71 exit 1
74 if [ ! -d "$USERDIR" ]; then
75 echo "Could not find user directory $USERDIR"
76 exit 1
80 if test "x$WMAKER_USER_ROOT" = "x"; then
81 cd "$USERDIR"
82 GSDIR="$USERDIR/GNUstep"
83 if [ ! -d "$GSDIR" ]; then
84 echo "Creating $GSDIR user directory"
85 make_dir "$GSDIR"
87 else
88 GSDIR="$WMAKER_USER_ROOT"
89 if [ ! -d "$GSDIR" ]; then
90 # in this case, and in this case only, mkdir needs -p option
91 mkdir -p $GSDIR || {
92 echo "Directory specified in WMAKER_USER_ROOT environment variable does not exist and could not be created"
93 exit 1
95 chmod +rwx $GSDIR || exit 1
97 cd "$GSDIR"
98 cd ..
102 if [ ! -d "$GSDIR/Defaults" ]; then
103 make_dir "$GSDIR/Defaults"
106 echo "Copying defaults database..."
108 FILES="$(cd "$GLOBALDEFDIR" && ls -d *)"
109 all=""
110 for i in $FILES; do
111 if [ ! -d "$GLOBALDEFDIR/$i" ]; then
112 if [ -f "$GSDIR/Defaults/$i" -a -z "$BATCH" ]; then
113 echo "The configuration file \"$i\" already exists in your defaults database."
114 echo "Do you wish to replace it? <y/n/a> [n] $all"
115 if [ "$all" != "a" ]; then
116 read foo
117 if [ "$foo" = "a" -o "$foo" = "A" ]; then
118 all="a"
121 if [ "$foo" = "y" -o "$foo" = "Y" -o "$all" = "a" ]; then
122 copy "$GLOBALDEFDIR/$i" "$GSDIR/Defaults/$i"
124 else
125 copy "$GLOBALDEFDIR/$i" "$GSDIR/Defaults/$i"
128 done
130 GenerateMenu
132 if [ ! -d "$GSDIR/Library/Icons/" ]; then
133 echo "Creating icon library directory $GSDIR/Library/Icons"
134 if [ ! -d "$GSDIR/Library" ]; then
135 make_dir "$GSDIR/Library"
137 make_dir "$GSDIR/Library/Icons"
141 if [ ! -d "$GSDIR/Library/WindowMaker/" ]; then
142 echo "Creating WindowMaker data library directory $GSDIR/Library/WindowMaker"
143 if [ ! -d "$GSDIR/Library" ]; then
144 make_dir "$GSDIR/Library"
146 make_dir "$GSDIR/Library/WindowMaker"
149 if [ ! -d "$GSDIR/Library/WindowMaker/Styles" ]; then
150 echo "Creating style library $GSDIR/Library/WindowMaker/Styles"
151 make_dir "$GSDIR/Library/WindowMaker/Styles"
155 if [ ! -d "$GSDIR/Library/WindowMaker/Themes" ]; then
156 echo "Creating theme library $GSDIR/Library/WindowMaker/Themes"
157 make_dir "$GSDIR/Library/WindowMaker/Themes"
161 if [ ! -d "$GSDIR/Library/WindowMaker/Backgrounds" ]; then
162 echo "Creating bg image library $GSDIR/Library/WindowMaker/Backgrounds"
163 make_dir "$GSDIR/Library/WindowMaker/Backgrounds"
164 else
165 echo "Default Backgrounds directory already exists. Skipping..."
169 if [ ! -d "$GSDIR/Library/WindowMaker/IconSets" ]; then
170 echo "Creating icon setup library $GSDIR/Library/WindowMaker/IconSets"
171 make_dir "$GSDIR/Library/WindowMaker/IconSets"
172 else
173 echo "Default IconSets directory already exists. Skipping..."
177 if [ ! -d "$GSDIR/Library/WindowMaker/Pixmaps" ]; then
178 echo "Creating pixmap library $GSDIR/Library/WindowMaker/Pixmaps"
179 make_dir "$GSDIR/Library/WindowMaker/Pixmaps"
180 else
181 echo "Default Pixmaps directory already exists. Skipping..."
185 if [ ! -d "$GSDIR/Library/WindowMaker/CachedPixmaps" ]; then
186 make_dir "$GSDIR/Library/WindowMaker/CachedPixmaps"
189 if [ ! -d "$GSDIR/Library/WindowMaker/WPrefs" ]; then
190 make_dir "$GSDIR/Library/WindowMaker/WPrefs"
193 if test -z "#LITE#" ; then
194 FILES="$(cd "$GLOBALDIR" && ls menu menu.* plmenu plmenu.?? wmmacros)"
195 for i in $FILES; do
196 # xx herbert
197 if [ -f "$GSDIR/Library/WindowMaker/$i" -a -z "$BATCH" ]; then
198 # /xx herbert
199 echo "The file \"$i\" already exists in $GSDIR/Library/WindowMaker"
200 echo "Do you wish to replace it? <y/n/a> [n] $all"
201 if [ "$all" != "a" ]; then
202 read foo
203 if [ "$foo" = "a" -o "$foo" = "A" ]; then
204 all="a"
207 if [ "$foo" = "y" -o "$foo" = "Y" -o "$foo" = "a" ]; then
208 copy "$GLOBALDIR/$i" "$GSDIR/Library/WindowMaker/$i"
210 else
211 copy "$GLOBALDIR/$i" "$GSDIR/Library/WindowMaker/$i"
213 done
216 cp "$GLOBALDIR/README.themes" "$GSDIR/Library/WindowMaker"
217 cp "$GLOBALDIR/README" "$GSDIR/Library/WindowMaker"
219 test -f "$GSDIR/Library/WindowMaker/autostart" || \
220 cp "$GLOBALDIR/autostart.sh" "$GSDIR/Library/WindowMaker/autostart"
221 chmod +rx "$GSDIR/Library/WindowMaker/autostart"
223 test -f "$GSDIR/Library/WindowMaker/exitscript" || \
224 cp "$GLOBALDIR/exitscript.sh" "$GSDIR/Library/WindowMaker/exitscript"
225 chmod +rx "$GSDIR/Library/WindowMaker/exitscript"
227 # xx herbert
228 if test -n "$BATCH" ; then
229 echo "Installation Finished"
230 exit 0
232 # /xx herbert
236 #######################
238 DATE="$(date +%b%d.%T)"
240 show_end_message() {
242 echo
243 echo "Installation Finished"
244 echo
245 echo "There are menus in 2 different file formats. The plain text format and"
246 echo "the property list format. The plain text format is more flexible, but"
247 echo "the menu in the property list format can be edited graphically. The"
248 echo "menu that will be used by default is the property list one. Read"
249 echo " $GSDIR/Library/WindowMaker/README"
250 echo "for information on how to change it."
251 if [ "${inst_menu%.*}" = "menu" ]; then
252 echo "However, since you have locale set to $LOCALE and plmenu for such locale"
253 echo "was not found, your WMRootMenu contains path to text formated menu:"
254 echo " $GSDIR/Library/WindowMaker/$inst_menu"
258 wmaker_found=0
259 for xinit in .xinitrc .Xclients .xsession; do
260 test ! -f "$HOME/$xinit" && continue
261 res="$(grep wmaker "$HOME/$xinit")"
262 if test "x$res" != x; then
263 wmaker_found=1
264 break
266 done
267 if test "$wmaker_found" = 1; then
268 echo "Found Window Maker to already be your default window manager."
269 show_end_message
270 exit 0
274 trap "show_end_message;exit" 2
276 show_end_message