Don't try to force year into a 19xx format
[mmh] / etc / mhn.defaults.sh
1 #!/bin/sh
2 #
3 # mhn.defaults.sh -- create extra profile file for MIME handling
4 #
5 # $Id$
6 #
7 # USAGE: mhn.defaults.sh [ search-path [ search-prog ]]
8
9 # If a search path is passed to the script, we
10 # use that, else we use a default search path.
11 if [ -n "$1" ]; then
12     SEARCHPATH=$1
13 else
14     SEARCHPATH="$PATH:/usr/demo/SOUND"
15 fi
16
17 # If a search program is passed to the script, we
18 # use that, else we use a default search program.
19 if [ -n "$2" ]; then
20     SEARCHPROG=$2
21 else
22     SEARCHPROG="mhn.find.sh"
23 fi
24
25 # put output into a temporary file, so we
26 # can sort it before output.
27 TMP=/tmp/nmh_temp.$$
28 trap "rm -f $TMP" 0 1 2 3 13 15
29
30 echo "mhstore-store-text: %m%P.txt" >> $TMP
31 echo "mhstore-store-text/richtext: %m%P.rt" >> $TMP
32 echo "mhstore-store-video/mpeg: %m%P.mpg" >> $TMP
33 echo "mhstore-store-application/PostScript: %m%P.ps" >> $TMP
34
35 PGM="`$SEARCHPROG $SEARCHPATH xwud`"
36 if [ ! -z "$PGM" ]; then
37     XWUD="$PGM" X11DIR="`echo $PGM | awk -F/ '{ for(i=2;i<NF;i++)printf "/%s", $i;}'`"/
38 else
39     XWUD= X11DIR=
40 fi
41
42 PGM="`$SEARCHPROG $SEARCHPATH pbmtoxwd`"
43 if [ ! -z "$PGM" ]; then
44     PBM="$PGM" PBMDIR="`echo $PGM | awk -F/ '{ for(i=2;i<NF;i++)printf "/%s", $i;}'`"/
45 else
46     PBM= PBMDIR=
47 fi
48
49 PGM="`$SEARCHPROG $SEARCHPATH xv`"
50 if [ ! -z "$PGM" ]; then
51     echo "mhshow-show-image: %p$PGM -geometry =-0+0 '%f'" >> $TMP
52 elif [ ! -z $"PBM" -a ! -z "$XWUD" ]; then
53     echo "mhshow-show-image/gif: %p${PBMDIR}giftoppm | ${PBMDIR}ppmtopgm | ${PBMDIR}pgmtopbm | ${PBMDIR}pbmtoxwd | $XWUD -geometry =-0+0" >> $TMP
54     echo "mhshow-show-image/x-pbm: %p${PBMDIR}pbmtoxwd | $XWUD -geometry =-0+0" >> $TMP
55     echo "mhshow-show-image/x-pgm: %p${PBMDIR}pgmtopbm | ${PBMDIR}pbmtoxwd | $XWUD -geometry =-0+0" >> $TMP
56     echo "mhshow-show-image/x-ppm: %p${PBMDIR}ppmtopgm | ${PBMDIR}pgmtopbm | ${PBMDIR}pbmtoxwd | $XWUD -geometry =-0+0" >> $TMP
57     echo "mhshow-show-image/x-xwd: %p$XWUD -geometry =-0+0" >> $TMP
58
59     PGM="`$SEARCHPROG $SEARCHPATH djpeg`"
60     if [ ! -z "$PGM" ]; then
61         echo "mhshow-show-image/jpeg: %p$PGM -Pg | ${PBMDIR}ppmtopgm | ${PBMDIR}pgmtopbm | ${PBMDIR}pbmtoxwd | $XWUD -geometry =-0+0" >> $TMP
62     fi
63 fi
64
65 if [ -f "/dev/audioIU" ]; then
66     PGM="`$SEARCHPROG $SEARCHPATH recorder`"
67     if [ ! -z "$PGM" ]; then
68         echo "mhstore-store-audio/basic: %m%P.au" >> $TMP
69         echo "mhbuild-compose-audio/basic: ${AUDIODIR}recorder '%f' -au -pause > /dev/tty" >> $TMP
70         echo "mhshow-show-audio/basic: %p${AUDIODIR}splayer -au" >> $TMP
71     fi
72 elif [ -f "/dev/audio" ]; then
73     PGM="`$SEARCHPROG $SEARCHPATH raw2audio`"
74     if [ ! -z "$PGM" ]; then
75         AUDIODIR="`echo $PGM | awk -F/ '{ for(i=2;i<NF;i++)printf "/%s", $i;}'`"/
76         echo "mhstore-store-audio/basic: | ${AUDIODIR}raw2audio -e ulaw -s 8000 -c 1 > %m%P.au" >> $TMP
77         echo "mhstore-store-audio/x-next: %m%P.au" >> $TMP
78         AUDIOTOOL="`$SEARCHPROG $SEARCHPATH audiotool`"
79         if [ ! -z "$AUDIOTOOL" ]; then
80             echo "mhbuild-compose-audio/basic: $AUDIOTOOL '%f' && ${AUDIODIR}raw2audio -F < '%f'" >> $TMP
81         else
82             echo "mhbuild-compose-audio/basic: trap \"exit 0\" 2 && ${AUDIODIR}record | ${AUDIODIR}raw2audio -F" >> $TMP
83         fi
84         echo "mhshow-show-audio/basic: %p${AUDIODIR}raw2audio 2>/dev/null | ${AUDIODIR}play" >> $TMP
85
86         PGM="`$SEARCHPROG $SEARCHPATH adpcm_enc`"
87         if [ ! -z "$PGM" ]; then
88             DIR="`echo $PGM | awk -F/ '{ for(i=2;i<NF;i++)printf "/%s", $i;}'`"/
89             if [ ! -z "$AUDIOTOOL" ]; then
90                 echo "mhbuild-compose-audio/x-next: $AUDIOTOOL '%f' && ${DIR}adpcm_enc < '%f'" >> $TMP
91             else
92                 echo "mhbuild-compose-audio/x-next: ${AUDIODIR}record | ${DIR}adpcm_enc" >> $TMP
93             fi
94             echo "mhshow-show-audio/x-next: %p${DIR}adpcm_dec | ${AUDIODIR}play" >> $TMP
95         else
96             if [ ! -z "$AUDIOTOOL" ]; then
97                 echo "mhbuild-compose-audio/x-next: $AUDIOTOOL '%f'" >> $TMP
98             else
99                 echo "mhbuild-compose-audio/x-next: ${AUDIODIR}record" >> $TMP
100             fi
101             echo "mhshow-show-audio/x-next: %p${AUDIODIR}play" >> $TMP
102         fi
103     else
104         echo "mhbuild-compose-audio/basic: cat < /dev/audio" >> $TMP
105         echo "mhshow-show-audio/basic: %pcat > /dev/audio" >> $TMP
106     fi
107 fi
108
109 PGM="`$SEARCHPROG $SEARCHPATH mpeg_play`"
110 if [ ! -z "$PGM" ]; then
111         echo "mhshow-show-video/mpeg: %p$PGM '%f'" >> $TMP
112 fi
113
114 PGM="`$SEARCHPROG $SEARCHPATH lpr`"
115 if [ ! -z "$PGM" ]; then
116         echo "mhshow-show-application/PostScript: %plpr -Pps" >> $TMP
117 else
118     PGM="`$SEARCHPROG $SEARCHPATH lp`"
119     if [ ! -z "$PGM" ]; then    
120         echo "mhshow-show-application/PostScript: %plp -dps" >> $TMP
121     fi
122 fi
123
124 PGM="`$SEARCHPROG $SEARCHPATH ivs_replay`"
125 if [ ! -z "$PGM" ]; then
126         echo "mhshow-show-application/x-ivs: %p$PGM -o '%F'" >> $TMP
127 fi
128
129 echo "mhshow-suffix-text/html: .html" >> $TMP
130
131 # I'd like to check if netscape is available and use it preferentially to lynx,
132 # but only once I've added a new %-escape that makes more permanent temp files,
133 # so netscape -remote can be used (without -remote you get a complaint dialog
134 # that another netscape is already running and certain things can't be done).
135 PGM="`$SEARCHPROG $SEARCHPATH lynx`"
136 if [ ! -z "$PGM" ]; then
137         echo "mhshow-show-text/html: %p$PGM '%F'" >> $TMP
138 fi
139
140 PGM="`$SEARCHPROG $SEARCHPATH richtext`"
141 if [ ! -z "$PGM" ]; then
142         echo "mhshow-show-text/richtext: %p$PGM -p '%F'" >> $TMP
143 else
144     PGM="`$SEARCHPROG $SEARCHPATH rt2raw`"
145     if [ ! -z "$PGM" ]; then
146         echo "mhshow-show-text/richtext: %p$PGM < '%f' | fmt -78 | more" >> $TMP
147     fi
148 fi
149
150 # staroffice to read .doc files
151 PGM="`$SEARCHPROG $SEARCHPATH soffice`"
152 if [ ! -z "$PGM" ]; then
153         echo "mhshow-show-application/msword: %psoffice '%F'" >> $TMP
154         echo "mhshow-suffix-application/msword: .doc" >> $TMP
155 fi
156
157 PGM="`$SEARCHPROG $SEARCHPATH xterm`"
158 if [ ! -z "$PGM" ]; then
159         echo "mhshow-charset-iso-8859-1: xterm -fn '-*-*-medium-r-normal-*-*-120-*-*-c-*-iso8859-*' -e %s" >> $TMP
160 fi
161
162 # output a sorted version of the file
163 sort < $TMP
164
165 exit 0
166
167 : not until we get a "safe" postscript environment...
168
169 PGM="`$SEARCHPROG $SEARCHPATH pageview`"
170 if [ "$DISPLAY" = "unix:0.0" -a ! -z "$PGM" ]; then
171     echo "mhshow-show-application/PostScript: %p$PGM -" >> $TMP
172 else
173     PGM="`$SEARCHPROG $SEARCHPATH gs`"
174     if [ ! -z "$PGM" ]; then
175         echo "mhshow-show-application/PostScript: %p$PGM -- '%F'" >> $TMP
176         echo "mhshow-suffix-application/PostScript: .ps" >> $TMP
177     fi
178 fi
179
180 : have to experiment more with this
181
182 PGM="`$SEARCHPROG $SEARCHPATH ivs_record`"
183 if [ ! -z "$PGM" ]; then
184         echo "mhbuild-compose-application/x-ivs: $PGM -u localhost '%F'" >> $TMP
185 fi