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