Added application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
[mmh] / 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:/usr/demo/SOUND"
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 echo "mhstore-store-text: %m%P.txt" >> $TMP
29 echo "mhstore-store-text/richtext: %m%P.rt" >> $TMP
30 echo "mhstore-store-video/mpeg: %m%P.mpg" >> $TMP
31 echo "mhstore-store-application/PostScript: %m%P.ps" >> $TMP
32
33 PGM="`$SEARCHPROG $SEARCHPATH xwud`"
34 if [ ! -z "$PGM" ]; then
35     XWUD="$PGM" X11DIR="`echo $PGM | awk -F/ '{ for(i=2;i<NF;i++)printf "/%s", $i;}'`"/
36 else
37     XWUD= X11DIR=
38 fi
39
40 PGM="`$SEARCHPROG $SEARCHPATH pnmtoxwd`"
41 if [ ! -z "$PGM" ]; then
42     NETPBM="$PGM" NETPBMDIR="`echo $PGM | awk -F/ '{ for(i=2;i<NF;i++)printf "/%s", $i;}'`"/
43 else
44     NETPBM= NETPBMDIR=
45 fi
46
47 PGM="`$SEARCHPROG $SEARCHPATH xv`"
48 if [ ! -z "$PGM" ]; then
49     echo "mhshow-show-image: %p$PGM -geometry =-0+0 '%f'" >> $TMP
50 elif [ ! -z $"NETPBM" -a ! -z "$XWUD" ]; then
51     echo "mhshow-show-image/gif: %p${NETPBMDIR}giftopnm | ${NETPBMDIR}ppmtopgm | ${NETPBMDIR}pgmtopbm | ${NETPBMDIR}pnmtoxwd | $XWUD -geometry =-0+0" >> $TMP
52     echo "mhshow-show-image/x-pnm: %p${NETPBMDIR}pnmtoxwd | $XWUD -geometry =-0+0" >> $TMP
53     echo "mhshow-show-image/x-pgm: %p${NETPBMDIR}pgmtopbm | ${NETPBMDIR}pnmtoxwd | $XWUD -geometry =-0+0" >> $TMP
54     echo "mhshow-show-image/x-ppm: %p${NETPBMDIR}ppmtopgm | ${NETPBMDIR}pgmtopbm | ${NETPBMDIR}pnmtoxwd | $XWUD -geometry =-0+0" >> $TMP
55     echo "mhshow-show-image/x-xwd: %p$XWUD -geometry =-0+0" >> $TMP
56
57     PGM="`$SEARCHPROG $SEARCHPATH djpeg`"
58     if [ ! -z "$PGM" ]; then
59         echo "mhshow-show-image/jpeg: %p$PGM -Pg | ${NETPBMDIR}ppmtopgm | ${NETPBMDIR}pgmtopbm | ${NETPBMDIR}pnmtoxwd | $XWUD -geometry =-0+0" >> $TMP
60     fi
61 fi
62
63 if [ -f "/dev/audioIU" ]; then
64     PGM="`$SEARCHPROG $SEARCHPATH recorder`"
65     if [ ! -z "$PGM" ]; then
66         echo "mhstore-store-audio/basic: %m%P.au" >> $TMP
67         echo "mhbuild-compose-audio/basic: ${AUDIODIR}recorder '%f' -au -pause > /dev/tty" >> $TMP
68         echo "mhshow-show-audio/basic: %p${AUDIODIR}splayer -au" >> $TMP
69     fi
70 elif [ -f "/dev/audio" ]; then
71     PGM="`$SEARCHPROG $SEARCHPATH raw2audio`"
72     if [ ! -z "$PGM" ]; then
73         AUDIODIR="`echo $PGM | awk -F/ '{ for(i=2;i<NF;i++)printf "/%s", $i;}'`"/
74         echo "mhstore-store-audio/basic: | ${AUDIODIR}raw2audio -e ulaw -s 8000 -c 1 > %m%P.au" >> $TMP
75         echo "mhstore-store-audio/x-next: %m%P.au" >> $TMP
76         AUDIOTOOL="`$SEARCHPROG $SEARCHPATH audiotool`"
77         if [ ! -z "$AUDIOTOOL" ]; then
78             echo "mhbuild-compose-audio/basic: $AUDIOTOOL '%f' && ${AUDIODIR}raw2audio -F < '%f'" >> $TMP
79         else
80             echo "mhbuild-compose-audio/basic: trap \"exit 0\" 2 && ${AUDIODIR}record | ${AUDIODIR}raw2audio -F" >> $TMP
81         fi
82         echo "mhshow-show-audio/basic: %p${AUDIODIR}raw2audio 2>/dev/null | ${AUDIODIR}play" >> $TMP
83
84         PGM="`$SEARCHPROG $SEARCHPATH adpcm_enc`"
85         if [ ! -z "$PGM" ]; then
86             DIR="`echo $PGM | awk -F/ '{ for(i=2;i<NF;i++)printf "/%s", $i;}'`"/
87             if [ ! -z "$AUDIOTOOL" ]; then
88                 echo "mhbuild-compose-audio/x-next: $AUDIOTOOL '%f' && ${DIR}adpcm_enc < '%f'" >> $TMP
89             else
90                 echo "mhbuild-compose-audio/x-next: ${AUDIODIR}record | ${DIR}adpcm_enc" >> $TMP
91             fi
92             echo "mhshow-show-audio/x-next: %p${DIR}adpcm_dec | ${AUDIODIR}play" >> $TMP
93         else
94             if [ ! -z "$AUDIOTOOL" ]; then
95                 echo "mhbuild-compose-audio/x-next: $AUDIOTOOL '%f'" >> $TMP
96             else
97                 echo "mhbuild-compose-audio/x-next: ${AUDIODIR}record" >> $TMP
98             fi
99             echo "mhshow-show-audio/x-next: %p${AUDIODIR}play" >> $TMP
100         fi
101     else
102         echo "mhbuild-compose-audio/basic: cat < /dev/audio" >> $TMP
103         echo "mhshow-show-audio/basic: %pcat > /dev/audio" >> $TMP
104     fi
105 fi
106
107 PGM="`$SEARCHPROG $SEARCHPATH mpeg_play`"
108 if [ ! -z "$PGM" ]; then
109         echo "mhshow-show-video/mpeg: %p$PGM '%f'" >> $TMP
110 fi
111
112 PGM="`$SEARCHPROG $SEARCHPATH lpr`"
113 if [ ! -z "$PGM" ]; then
114         echo "mhshow-show-application/PostScript: %plpr -Pps" >> $TMP
115 else
116     PGM="`$SEARCHPROG $SEARCHPATH lp`"
117     if [ ! -z "$PGM" ]; then
118         echo "mhshow-show-application/PostScript: %plp -dps" >> $TMP
119     fi
120 fi
121
122 PGM="`$SEARCHPROG $SEARCHPATH ivs_replay`"
123 if [ ! -z "$PGM" ]; then
124         echo "mhshow-show-application/x-ivs: %p$PGM -o '%F'" >> $TMP
125 fi
126
127 cat <<EOF >> ${TMP}
128 mhshow-suffix-application/msword: .doc
129 mhshow-suffix-application/msword: .docx
130 mhshow-suffix-application/ogg: .ogg
131 mhshow-suffix-application/pdf: .pdf
132 mhshow-suffix-application/postscript: .ps
133 mhshow-suffix-application/rtf: .rtf
134 mhshow-suffix-application/vnd.ms-excel: .xla
135 mhshow-suffix-application/vnd.ms-excel: .xlc
136 mhshow-suffix-application/vnd.ms-excel: .xld
137 mhshow-suffix-application/vnd.ms-excel: .xll
138 mhshow-suffix-application/vnd.ms-excel: .xlm
139 mhshow-suffix-application/vnd.ms-excel: .xls
140 mhshow-suffix-application/vnd.openxmlformats-officedocument.spreadsheetml.sheet: .xlsx
141 mhshow-suffix-application/vnd.ms-excel: .xlt
142 mhshow-suffix-application/vnd.ms-excel: .xlw
143 mhshow-suffix-application/vnd.ms-powerpoint: .pot
144 mhshow-suffix-application/vnd.ms-powerpoint: .pps
145 mhshow-suffix-application/vnd.ms-powerpoint: .ppt
146 mhshow-suffix-application/vnd.ms-powerpoint: .ppz
147 mhshow-suffix-application/x-bzip2: .bz2
148 mhshow-suffix-application/x-cpio: .cpio
149 mhshow-suffix-application/x-dvi: .dvi
150 mhshow-suffix-application/x-gzip: .gz
151 mhshow-suffix-application/x-java-archive: .jar
152 mhshow-suffix-application/x-javascript: .js
153 mhshow-suffix-application/x-latex: .latex
154 mhshow-suffix-application/x-sh: .sh
155 mhshow-suffix-application/x-tar: .tar
156 mhshow-suffix-application/x-texinfo: .texinfo
157 mhshow-suffix-application/x-tex: .tex
158 mhshow-suffix-application/x-troff-man: .man
159 mhshow-suffix-application/x-troff-me: .me
160 mhshow-suffix-application/x-troff-ms: .ms
161 mhshow-suffix-application/x-troff: .t
162 mhshow-suffix-application/zip: .zip
163 mhshow-suffix-audio/basic: .au
164 mhshow-suffix-audio/midi: .midi
165 mhshow-suffix-audio/mpeg: .mp3
166 mhshow-suffix-audio/mpeg: .mpg
167 mhshow-suffix-audio/x-ms-wma: .wma
168 mhshow-suffix-audio/x-wav: .wav
169 mhshow-suffix-image/gif: .gif
170 mhshow-suffix-image/jpeg: .jpeg
171 mhshow-suffix-image/jpeg: .jpg
172 mhshow-suffix-image/png: .png
173 mhshow-suffix-image/tiff: .tif
174 mhshow-suffix-image/tiff: .tiff
175 mhshow-suffix-text/calendar: .ics
176 mhshow-suffix-text/css: .css
177 mhshow-suffix-text/html: .html
178 mhshow-suffix-text/rtf: .rtf
179 mhshow-suffix-text/sgml: .sgml
180 mhshow-suffix-text/xml: .xml
181 mhshow-suffix-video/mpeg: .mpeg
182 mhshow-suffix-video/mpeg: .mpg
183 mhshow-suffix-video/quicktime: .moov
184 mhshow-suffix-video/quicktime: .mov
185 mhshow-suffix-video/quicktime: .qt
186 mhshow-suffix-video/quicktime: .qtvr
187 mhshow-suffix-video/x-msvideo: .avi
188 mhshow-suffix-video/x-ms-wmv: .wmv
189 EOF
190
191 # I'd like to check if netscape is available and use it preferentially to lynx,
192 # but only once I've added a new %-escape that makes more permanent temp files,
193 # so netscape -remote can be used (without -remote you get a complaint dialog
194 # that another netscape is already running and certain things can't be done).
195 PGM="`$SEARCHPROG $SEARCHPATH lynx`"
196 if [ ! -z "$PGM" ]; then
197         echo "mhshow-show-text/html: %p$PGM '%F'" >> $TMP
198 fi
199
200 PGM="`$SEARCHPROG $SEARCHPATH richtext`"
201 if [ ! -z "$PGM" ]; then
202         echo "mhshow-show-text/richtext: %p$PGM -p '%F'" >> $TMP
203 else
204     PGM="`$SEARCHPROG $SEARCHPATH rt2raw`"
205     if [ ! -z "$PGM" ]; then
206         echo "mhshow-show-text/richtext: %p$PGM < '%f' | fmt -78 | more" >> $TMP
207     fi
208 fi
209
210 # staroffice to read .doc files
211 PGM="`$SEARCHPROG $SEARCHPATH soffice`"
212 if [ ! -z "$PGM" ]; then
213         echo "mhshow-show-application/msword: %psoffice '%F'" >> $TMP
214         echo "mhshow-suffix-application/msword: .doc" >> $TMP
215 fi
216
217 # output a sorted version of the file
218 sort < $TMP
219
220 exit 0
221
222 : not until we get a "safe" postscript environment...
223
224 PGM="`$SEARCHPROG $SEARCHPATH pageview`"
225 if [ "$DISPLAY" = "unix:0.0" -a ! -z "$PGM" ]; then
226     echo "mhshow-show-application/PostScript: %p$PGM -" >> $TMP
227 else
228     PGM="`$SEARCHPROG $SEARCHPATH gs`"
229     if [ ! -z "$PGM" ]; then
230         echo "mhshow-show-application/PostScript: %p$PGM -- '%F'" >> $TMP
231         echo "mhshow-suffix-application/PostScript: .ps" >> $TMP
232     fi
233 fi
234
235 : have to experiment more with this
236
237 PGM="`$SEARCHPROG $SEARCHPATH ivs_record`"
238 if [ ! -z "$PGM" ]; then
239         echo "mhbuild-compose-application/x-ivs: $PGM -u localhost '%F'" >> $TMP
240 fi