]> diplodocus.org Git - nmh/blob - etc/mhn.defaults.sh
Removed export of most of the variables in test/common.sh.in. The
[nmh] / etc / mhn.defaults.sh
1 #!/bin/sh
2 #
3 # mhn.defaults.sh -- create extra profile file for MIME handling
4 #
5 # USAGE: mhn.defaults.sh [ search-path [ search-prog ]]
6
7 # If a search path is passed to the script, we
8 # use that, else we use a default search path.
9 if [ -n "$1" ]; then
10 SEARCHPATH=$1
11 else
12 SEARCHPATH="$PATH"
13 fi
14
15 # If a search program is passed to the script, we
16 # use that, else we use a default search program.
17 if [ -n "$2" ]; then
18 SEARCHPROG=$2
19 else
20 SEARCHPROG="mhn.find.sh"
21 fi
22
23 # put output into a temporary file, so we
24 # can sort it before output.
25 TMP=/tmp/nmh_temp.$$
26 trap "rm -f $TMP" 0 1 2 3 13 15
27
28 cat >>"$TMP" <<'EOF'
29 mhstore-store-text: %m%P.txt
30 mhstore-store-text/html: %m%P.html
31 mhstore-store-text/richtext: %m%P.rt
32 mhstore-store-video/mpeg: %m%P.mpg
33 mhstore-store-application/PostScript: %m%P.ps
34 EOF
35
36 PGM=`$SEARCHPROG "$SEARCHPATH" xwud`
37 if [ ! -z "$PGM" ]; then
38 XWUD="$PGM" X11DIR="`echo $PGM | awk -F/ '{ for(i=2;i<NF;i++)printf "/%s", $i;}'`"/
39 else
40 XWUD= X11DIR=
41 fi
42
43 PGM=`$SEARCHPROG "$SEARCHPATH" pnmtoxwd`
44 if [ ! -z "$PGM" ]; then
45 NETPBM="$PGM" NETPBMDIR="`echo $PGM | awk -F/ '{ for(i=2;i<NF;i++)printf "/%s", $i;}'`"/
46 else
47 NETPBM= NETPBMDIR=
48 fi
49
50 PGM=`$SEARCHPROG "$SEARCHPATH" xv`
51 if [ ! -z "$PGM" ]; then
52 echo "mhshow-show-image: %l$PGM -geometry =-0+0 %f" >> $TMP
53 elif [ ! -z $"NETPBM" -a ! -z "$XWUD" ]; then
54 echo "mhshow-show-image/gif: %l${NETPBMDIR}giftopnm | ${NETPBMDIR}ppmtopgm | ${NETPBMDIR}pgmtopbm | ${NETPBMDIR}pnmtoxwd | $XWUD -geometry =-0+0" >> $TMP
55 echo "mhshow-show-image/x-pnm: %l${NETPBMDIR}pnmtoxwd | $XWUD -geometry =-0+0" >> $TMP
56 echo "mhshow-show-image/x-pgm: %l${NETPBMDIR}pgmtopbm | ${NETPBMDIR}pnmtoxwd | $XWUD -geometry =-0+0" >> $TMP
57 echo "mhshow-show-image/x-ppm: %l${NETPBMDIR}ppmtopgm | ${NETPBMDIR}pgmtopbm | ${NETPBMDIR}pnmtoxwd | $XWUD -geometry =-0+0" >> $TMP
58 echo "mhshow-show-image/x-xwd: %l$XWUD -geometry =-0+0" >> $TMP
59
60 PGM=`$SEARCHPROG "$SEARCHPATH" djpeg`
61 if [ ! -z "$PGM" ]; then
62 echo "mhshow-show-image/jpeg: %l$PGM -Pg | ${NETPBMDIR}ppmtopgm | ${NETPBMDIR}pgmtopbm | ${NETPBMDIR}pnmtoxwd | $XWUD -geometry =-0+0" >> $TMP
63 fi
64 fi
65
66 if [ -f "/dev/audioIU" ]; then
67 PGM=`$SEARCHPROG "$SEARCHPATH" recorder`
68 if [ ! -z "$PGM" ]; then
69 echo "mhstore-store-audio/basic: %m%P.au" >> $TMP
70 echo "mhbuild-compose-audio/basic: ${AUDIODIR}recorder %f -au -pause > /dev/tty" >> $TMP
71 echo "mhshow-show-audio/basic: %l${AUDIODIR}splayer -au" >> $TMP
72 fi
73 elif [ -f "/dev/audio" ]; then
74 PGM=`$SEARCHPROG "$SEARCHPATH" raw2audio`
75 if [ ! -z "$PGM" ]; then
76 AUDIODIR="`echo $PGM | awk -F/ '{ for(i=2;i<NF;i++)printf "/%s", $i;}'`"/
77 echo "mhstore-store-audio/basic: | ${AUDIODIR}raw2audio -e ulaw -s 8000 -c 1 > %m%P.au" >> $TMP
78 echo "mhstore-store-audio/x-next: %m%P.au" >> $TMP
79 AUDIOTOOL=`$SEARCHPROG "$SEARCHPATH" audiotool`
80 if [ ! -z "$AUDIOTOOL" ]; then
81 echo "mhbuild-compose-audio/basic: $AUDIOTOOL %f && ${AUDIODIR}raw2audio -F < %f" >> $TMP
82 else
83 echo "mhbuild-compose-audio/basic: trap \"exit 0\" 2 && ${AUDIODIR}record | ${AUDIODIR}raw2audio -F" >> $TMP
84 fi
85 echo "mhshow-show-audio/basic: %l${AUDIODIR}raw2audio 2>/dev/null | ${AUDIODIR}play" >> $TMP
86
87 PGM=`$SEARCHPROG "$SEARCHPATH" adpcm_enc`
88 if [ ! -z "$PGM" ]; then
89 DIR="`echo $PGM | awk -F/ '{ for(i=2;i<NF;i++)printf "/%s", $i;}'`"/
90 if [ ! -z "$AUDIOTOOL" ]; then
91 echo "mhbuild-compose-audio/x-next: $AUDIOTOOL %f && ${DIR}adpcm_enc < %f" >> $TMP
92 else
93 echo "mhbuild-compose-audio/x-next: ${AUDIODIR}record | ${DIR}adpcm_enc" >> $TMP
94 fi
95 echo "mhshow-show-audio/x-next: %l${DIR}adpcm_dec | ${AUDIODIR}play" >> $TMP
96 else
97 if [ ! -z "$AUDIOTOOL" ]; then
98 echo "mhbuild-compose-audio/x-next: $AUDIOTOOL %f" >> $TMP
99 else
100 echo "mhbuild-compose-audio/x-next: ${AUDIODIR}record" >> $TMP
101 fi
102 echo "mhshow-show-audio/x-next: %l${AUDIODIR}play" >> $TMP
103 fi
104 else
105 echo "mhbuild-compose-audio/basic: cat < /dev/audio" >> $TMP
106 echo "mhshow-show-audio/basic: %lcat > /dev/audio" >> $TMP
107 fi
108 fi
109
110 ####
111 #### mhbuild-disposition-<type>[/<subtype>] entries are used by the
112 #### WhatNow attach for deciding whether the Content-Disposition
113 #### should be 'attachment' or 'inline'. Only those values are
114 #### supported.
115 ####
116 cat <<EOF >>${TMP}
117 mhbuild-disposition-text/calendar: inline
118 mhbuild-disposition-message/rfc822: inline
119 EOF
120
121 PGM=`$SEARCHPROG "$SEARCHPATH" mpeg_play`
122 if [ ! -z "$PGM" ]; then
123 echo "mhshow-show-video/mpeg: %l$PGM %f" >> $TMP
124 fi
125
126 PGM=`$SEARCHPROG "$SEARCHPATH" okular`
127 if [ ! -z "$PGM" ]; then
128 echo "mhshow-show-application/PostScript: %l$PGM %F" >> $TMP
129 else
130 PGM=`$SEARCHPROG "$SEARCHPATH" evince`
131 if [ ! -z "$PGM" ]; then
132 echo "mhshow-show-application/PostScript: %l$PGM %F" >> $TMP
133 else
134 PGM=`$SEARCHPROG "$SEARCHPATH" gv`
135 if [ ! -z "$PGM" ]; then
136 echo "mhshow-show-application/PostScript: %l$PGM %F" >> $TMP
137 fi
138 fi
139 fi
140
141 PGM=`$SEARCHPROG "$SEARCHPATH" acroread`
142 if [ ! -z "$PGM" ]; then
143 echo "mhshow-show-application/pdf: %l$PGM %F" >> $TMP
144 else
145 PGM=`$SEARCHPROG "$SEARCHPATH" okular`
146 if [ ! -z "$PGM" ]; then
147 echo "mhshow-show-application/pdf: %l$PGM %F" >> $TMP
148 else
149 PGM=`$SEARCHPROG "$SEARCHPATH" evince`
150 if [ ! -z "$PGM" ]; then
151 echo "mhshow-show-application/pdf: %l$PGM %F" >> $TMP
152 else
153 PGM=`$SEARCHPROG "$SEARCHPATH" xpdf`
154 if [ ! -z "$PGM" ]; then
155 echo "mhshow-show-application/pdf: %l$PGM %F" >> $TMP
156 else
157 PGM=`$SEARCHPROG "$SEARCHPATH" gv`
158 if [ ! -z "$PGM" ]; then
159 echo "mhshow-show-application/pdf: %l$PGM %F" >> $TMP
160 fi
161 fi
162 fi
163 fi
164 fi
165
166 PGM=`$SEARCHPROG "$SEARCHPATH" ivs_replay`
167 if [ ! -z "$PGM" ]; then
168 echo "mhshow-show-application/x-ivs: %l$PGM -o %F" >> $TMP
169 fi
170
171 # The application/vnd.openxmlformats-officedocument.wordprocessingml.document
172 # through application/onenote associations are from
173 # http://technet.microsoft.com/en-us/library/cc179224.aspx
174
175 cat <<EOF >> ${TMP}
176 mhshow-suffix-application/msword: .doc
177 mhshow-suffix-application/ogg: .ogg
178 mhshow-suffix-application/pdf: .pdf
179 mhshow-suffix-application/postscript: .ps
180 mhshow-suffix-application/rtf: .rtf
181 mhshow-suffix-application/vnd.ms-excel: .xla
182 mhshow-suffix-application/vnd.ms-excel: .xlc
183 mhshow-suffix-application/vnd.ms-excel: .xld
184 mhshow-suffix-application/vnd.ms-excel: .xll
185 mhshow-suffix-application/vnd.ms-excel: .xlm
186 mhshow-suffix-application/vnd.ms-excel: .xls
187 mhshow-suffix-application/vnd.ms-excel: .xlt
188 mhshow-suffix-application/vnd.ms-excel: .xlw
189 mhshow-suffix-application/vnd.ms-powerpoint: .pot
190 mhshow-suffix-application/vnd.ms-powerpoint: .pps
191 mhshow-suffix-application/vnd.ms-powerpoint: .ppt
192 mhshow-suffix-application/vnd.ms-powerpoint: .ppz
193 mhshow-suffix-application/vnd.openxmlformats-officedocument.wordprocessingml.document: .docx
194 mhshow-suffix-application/vnd.ms-word.document.macroEnabled.12: .docm
195 mhshow-suffix-application/vnd.openxmlformats-officedocument.wordprocessingml.template: .dotx
196 mhshow-suffix-application/vnd.ms-word.template.macroEnabled.12: .dotm
197 mhshow-suffix-application/vnd.openxmlformats-officedocument.spreadsheetml.sheet: .xlsx
198 mhshow-suffix-application/vnd.ms-excel.sheet.macroEnabled.12: .xlsm
199 mhshow-suffix-application/vnd.openxmlformats-officedocument.spreadsheetml.template: .xltx
200 mhshow-suffix-application/vnd.ms-excel.template.macroEnabled.12: .xltm
201 mhshow-suffix-application/vnd.ms-excel.sheet.binary.macroEnabled.12: .xlsb
202 mhshow-suffix-application/vnd.ms-excel.addin.macroEnabled.12: .xlam
203 mhshow-suffix-application/vnd.openxmlformats-officedocument.presentationml.presentation: .pptx
204 mhshow-suffix-application/vnd.ms-powerpoint.presentation.macroEnabled.12: .pptm
205 mhshow-suffix-application/vnd.openxmlformats-officedocument.presentationml.slideshow: .ppsx
206 mhshow-suffix-application/vnd.ms-powerpoint.slideshow.macroEnabled.12: .ppsm
207 mhshow-suffix-application/vnd.openxmlformats-officedocument.presentationml.template: .potx
208 mhshow-suffix-application/vnd.ms-powerpoint.template.macroEnabled.12: .potm
209 mhshow-suffix-application/vnd.ms-powerpoint.addin.macroEnabled.12: .ppam
210 mhshow-suffix-application/vnd.openxmlformats-officedocument.presentationml.slide: .sldx
211 mhshow-suffix-application/vnd.ms-powerpoint.slide.macroEnabled.12: .sldm
212 mhshow-suffix-application/onenote: .onetoc
213 mhshow-suffix-application/onenote: .onetoc2
214 mhshow-suffix-application/onenote: .onetmp
215 mhshow-suffix-application/onenote: .onepkg
216 mhshow-suffix-application/x-bzip2: .bz2
217 mhshow-suffix-application/x-cpio: .cpio
218 mhshow-suffix-application/x-dvi: .dvi
219 mhshow-suffix-application/x-gzip: .gz
220 mhshow-suffix-application/x-java-archive: .jar
221 mhshow-suffix-application/x-javascript: .js
222 mhshow-suffix-application/x-latex: .latex
223 mhshow-suffix-application/x-sh: .sh
224 mhshow-suffix-application/x-tar: .tar
225 mhshow-suffix-application/x-texinfo: .texinfo
226 mhshow-suffix-application/x-tex: .tex
227 mhshow-suffix-application/x-troff-man: .man
228 mhshow-suffix-application/x-troff-me: .me
229 mhshow-suffix-application/x-troff-ms: .ms
230 mhshow-suffix-application/x-troff: .t
231 mhshow-suffix-application/zip: .zip
232 mhshow-suffix-audio/basic: .au
233 mhshow-suffix-audio/midi: .midi
234 mhshow-suffix-audio/mpeg: .mp3
235 mhshow-suffix-audio/mpeg: .mpg
236 mhshow-suffix-audio/x-ms-wma: .wma
237 mhshow-suffix-audio/x-wav: .wav
238 mhshow-suffix-image/gif: .gif
239 mhshow-suffix-image/jpeg: .jpeg
240 mhshow-suffix-image/jpeg: .jpg
241 mhshow-suffix-image/png: .png
242 mhshow-suffix-image/tiff: .tif
243 mhshow-suffix-image/tiff: .tiff
244 mhshow-suffix-text/calendar: .ics
245 mhshow-suffix-text/css: .css
246 mhshow-suffix-text/html: .html
247 mhshow-suffix-text/rtf: .rtf
248 mhshow-suffix-text/sgml: .sgml
249 mhshow-suffix-text/xml: .xml
250 mhshow-suffix-video/mpeg: .mpeg
251 mhshow-suffix-video/mpeg: .mpg
252 mhshow-suffix-video/quicktime: .moov
253 mhshow-suffix-video/quicktime: .mov
254 mhshow-suffix-video/quicktime: .qt
255 mhshow-suffix-video/quicktime: .qtvr
256 mhshow-suffix-video/x-msvideo: .avi
257 mhshow-suffix-video/x-ms-wmv: .wmv
258 EOF
259
260 # I'd like to check if netscape is available and use it preferentially to lynx,
261 # but only once I've added a new %-escape that makes more permanent temp files,
262 # so netscape -remote can be used (without -remote you get a complaint dialog
263 # that another netscape is already running and certain things can't be done).
264 PGM=`$SEARCHPROG "$SEARCHPATH" w3m`
265 if [ ! -z "$PGM" ]; then
266 echo 'mhshow-show-text/html: charset=%{charset}; '"\
267 %l$PGM"' -dump ${charset:+-I "$charset"} -T text/html %F' >> $TMP
268 echo 'mhfixmsg-format-text/html: charset=%{charset}; '"\
269 $PGM "'-dump ${charset:+-I "$charset"} -O utf-8 -T text/html %F' >> $TMP
270 else
271 PGM=`$SEARCHPROG "$SEARCHPATH" lynx`
272 if [ ! -z "$PGM" ]; then
273 echo 'mhshow-show-text/html: charset=%{charset}; '"\
274 %l$PGM"' -child -dump -force-html ${charset:+--assume_charset "$charset"} %F' >> $TMP
275 #### lynx indents with 3 spaces, remove them and any trailing spaces.
276 echo 'mhfixmsg-format-text/html: charset=%{charset}; '"\
277 $PGM "'-child -dump -force_html ${charset:+--assume_charset "$charset"} %F | '"\
278 expand | sed -e 's/^ //' -e 's/ *$//'" >> $TMP
279 else
280 PGM=`$SEARCHPROG "$SEARCHPATH" elinks`
281 if [ ! -z "$PGM" ]; then
282 echo "mhshow-show-text/html: $PGM -dump -force-html \
283 -eval 'set document.browse.margin_width = 0' %F" >> $TMP
284 echo "mhfixmsg-format-text/html: $PGM -dump -force-html \
285 -no-numbering -eval 'set document.browse.margin_width = 0' %F" >> $TMP
286 fi
287 fi
288 fi
289
290 PGM=`$SEARCHPROG "$SEARCHPATH" richtext`
291 if [ ! -z "$PGM" ]; then
292 echo "mhshow-show-text/richtext: %l$PGM -p %F" >> $TMP
293 else
294 PGM=`$SEARCHPROG "$SEARCHPATH" rt2raw`
295 if [ ! -z "$PGM" ]; then
296 echo "mhshow-show-text/richtext: %l$PGM < %f | fmt -78 | more" >> $TMP
297 fi
298 fi
299
300 # staroffice to read .doc files
301 PGM=`$SEARCHPROG "$SEARCHPATH" soffice`
302 if [ ! -z "$PGM" ]; then
303 echo "mhshow-show-application/msword: %l$PGM %F" >> $TMP
304 fi
305
306 # This entry is used to retrieve external-body types that use a "url"
307 # access-type.
308 case "`uname`" in
309 FreeBSD)
310 echo "nmh-access-url: fetch -o -" >> $TMP
311 ;;
312 *)
313 PGM=`$SEARCHPROG "$SEARCHPATH" curl`
314 if [ ! -z "$PGM" ]; then
315 echo "nmh-access-url: $PGM -L" >> $TMP
316 fi
317 ;;
318 esac
319
320 # output a sorted version of the file
321 sort < $TMP
322
323 exit 0
324
325
326 ###############################################################################
327 ###############################################################################
328 ####
329 #### Note the exit 0 above; everything below is unused.
330 ####
331 ###############################################################################
332 ###############################################################################
333
334 : have to experiment more with this
335
336 PGM=`$SEARCHPROG "$SEARCHPATH" ivs_record`
337 if [ ! -z "$PGM" ]; then
338 echo "mhbuild-compose-application/x-ivs: $PGM -u localhost %F" >> $TMP
339 fi