File: wmaker.inst.in

package info (click to toggle)
wmaker 0.96.0-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 17,416 kB
  • sloc: ansic: 99,483; sh: 7,068; perl: 3,423; makefile: 1,647; lisp: 219; python: 34
file content (276 lines) | stat: -rw-r--r-- 6,794 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
#!/bin/sh
#
# Install Window Maker for the current user
#

# xx herbert
if test "x$1" = "x--batch" ; then
  BATCH="1"
else
  BATCH=""
fi
# /xx herbert

# name of menu file we install (menu, plmenu)
inst_menu=""

LOCALE="${LC_ALL-${LC_MESSAGES-$LANG}}"

# directory where system wide configuration is stored
GLOBALDIR="#pkgdatadir#"
GLOBALDEFDIR="#sysconfdir#"

USERDIR="$HOME"

VERSION="#version#"

BINDIR="#bindir#"

make_dir() {
	mkdir "$1"
	chmod +rwx "$1"
}

#
# Copy files considering special cases
#
copy() {
	source="$1"
	target="$2"
	file="$(basename "$source")"
	rm -f "$target"
	if [ "$file" = "WindowMaker" ]; then
		sed -e "s|~/GNUstep|$GSDIR|g" "$source" > "$target"
	else
		if test "x$WMAKER_USER_ROOT" != "x"; then
			sed -e "s|\$HOME/GNUstep|$GSDIR|g" \
					"$source" > "$target"
		fi
	fi
}

#
# Generate WMRootmenu
#
GenerateMenu() {
	wmgenmenu > $GSDIR/Defaults/WMRootMenu
}

echo "Installing WindowMaker $VERSION for current user..."


if [ ! -d "$GLOBALDIR" ]; then
      echo "Could not find global data files"
      echo "Make sure you have installed Window Maker correctly"
      exit 1
fi

if [ ! -d "$GLOBALDEFDIR" ]; then
      echo "Could not find global configurations files"
      echo "Make sure you have installed Window Maker correctly"
      exit 1
fi

if [ ! -d "$USERDIR" ]; then
      echo "Could not find user directory $USERDIR"
      exit 1
fi


if test "x$WMAKER_USER_ROOT" = "x"; then
	cd "$USERDIR"
	GSDIR="$USERDIR/GNUstep"
	if [ ! -d "$GSDIR" ]; then
		echo "Creating $GSDIR user directory"
		make_dir "$GSDIR"
	fi
else
	GSDIR="$WMAKER_USER_ROOT"
	if [ ! -d "$GSDIR" ]; then
		# in this case, and in this case only, mkdir needs -p option
		mkdir -p $GSDIR || {
		    echo "Directory specified in WMAKER_USER_ROOT environment variable does not exist and could not be created"
		    exit 1
		}
		chmod +rwx $GSDIR || exit 1
	fi
	cd "$GSDIR"
	cd ..
fi


if [ ! -d "$GSDIR/Defaults" ]; then
	make_dir "$GSDIR/Defaults"
fi

echo "Copying defaults database..."

FILES="$(cd "$GLOBALDEFDIR" && ls -d *)"
all=""
for i in $FILES; do
	if [ ! -d "$GLOBALDEFDIR/$i" ]; then
		if [ -f "$GSDIR/Defaults/$i" -a -z "$BATCH" ]; then
			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
			fi
			if [ "$foo" = "y" -o "$foo" = "Y" -o "$all" = "a" ]; then
				copy "$GLOBALDEFDIR/$i" "$GSDIR/Defaults/$i"
			fi
		else
			copy "$GLOBALDEFDIR/$i" "$GSDIR/Defaults/$i"
		fi
	fi
done

	GenerateMenu

if [ ! -d "$GSDIR/Library/Icons/" ]; then
      echo "Creating icon library directory $GSDIR/Library/Icons"
      if [ ! -d "$GSDIR/Library" ]; then
              make_dir "$GSDIR/Library"
      fi
      make_dir "$GSDIR/Library/Icons"
fi


if [ ! -d "$GSDIR/Library/WindowMaker/" ]; then
      echo "Creating WindowMaker data library directory $GSDIR/Library/WindowMaker"
      if [ ! -d "$GSDIR/Library" ]; then
              make_dir "$GSDIR/Library"
      fi
      make_dir "$GSDIR/Library/WindowMaker"
fi

if [ ! -d "$GSDIR/Library/WindowMaker/Styles" ]; then
	echo "Creating style library $GSDIR/Library/WindowMaker/Styles"
	make_dir "$GSDIR/Library/WindowMaker/Styles"
fi


if [ ! -d "$GSDIR/Library/WindowMaker/Themes" ]; then
	echo "Creating theme library $GSDIR/Library/WindowMaker/Themes"
	make_dir  "$GSDIR/Library/WindowMaker/Themes"
fi


if [ ! -d "$GSDIR/Library/WindowMaker/Backgrounds" ]; then
	echo "Creating bg image library $GSDIR/Library/WindowMaker/Backgrounds"
	make_dir  "$GSDIR/Library/WindowMaker/Backgrounds"
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"
	make_dir  "$GSDIR/Library/WindowMaker/IconSets"
else
	echo "Default IconSets directory already exists. Skipping..."
fi


if [ ! -d "$GSDIR/Library/WindowMaker/Pixmaps" ]; then
	echo "Creating pixmap library $GSDIR/Library/WindowMaker/Pixmaps"
	make_dir  "$GSDIR/Library/WindowMaker/Pixmaps"
else
	echo "Default Pixmaps directory already exists. Skipping..."
fi


if [ ! -d "$GSDIR/Library/WindowMaker/CachedPixmaps" ]; then
	make_dir "$GSDIR/Library/WindowMaker/CachedPixmaps"
fi

if [ ! -d "$GSDIR/Library/WindowMaker/WPrefs" ]; then
	make_dir "$GSDIR/Library/WindowMaker/WPrefs"
fi

if test -z "#LITE#" ; then
FILES="$(cd "$GLOBALDIR" && ls menu menu.* plmenu plmenu.?? wmmacros)"
for i in $FILES; do
# xx herbert
	if [ -f "$GSDIR/Library/WindowMaker/$i" -a -z "$BATCH" ]; then
# /xx herbert
		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
			copy "$GLOBALDIR/$i" "$GSDIR/Library/WindowMaker/$i"
		fi
	else
		copy "$GLOBALDIR/$i" "$GSDIR/Library/WindowMaker/$i"
	fi
done
fi

cp "$GLOBALDIR/README.themes" "$GSDIR/Library/WindowMaker"
cp "$GLOBALDIR/README" "$GSDIR/Library/WindowMaker"

test -f "$GSDIR/Library/WindowMaker/autostart" || \
    cp "$GLOBALDIR/autostart.sh" "$GSDIR/Library/WindowMaker/autostart"
chmod +rx "$GSDIR/Library/WindowMaker/autostart"

test -f "$GSDIR/Library/WindowMaker/exitscript" || \
    cp "$GLOBALDIR/exitscript.sh" "$GSDIR/Library/WindowMaker/exitscript"
chmod +rx "$GSDIR/Library/WindowMaker/exitscript"

# xx herbert
if test -n "$BATCH" ; then
  echo "Installation Finished"
  exit 0
fi
# /xx herbert


#
#######################

DATE="$(date +%b%d.%T)"

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
}

wmaker_found=0
for xinit in .xinitrc .Xclients .xsession; do
     test ! -f "$HOME/$xinit" && continue
	 res="$(grep wmaker "$HOME/$xinit")"
     if test "x$res" != x; then
     	wmaker_found=1
	break
     fi
done
if test "$wmaker_found" = 1; then
	echo "Found Window Maker to already be your default window manager."
	show_end_message
	exit 0
fi


trap "show_end_message;exit" 2

show_end_message