#!/bin/sh
#
# Script to make drag and drop in BeOS possible (using xicon
#

if [ $# -lt 1 ]
then
	echo "Drop a Word file on the icon to convert it"
	sleep 2
	exit 0
fi

# Determine relevant directories
	tmp_dir="/tmp"
	GSPATH="/boot/apps/Ghostscript"
                        
out_file=$tmp_dir"/antiword.$$.ps"
err_file=$tmp_dir"/antiword.$$.err"

# Determine the paper size
paper_size=letter

# Make the PostScript file
antiword -p $paper_size -i 0 "$@" 2>$err_file >$out_file
if [ $? -ne 0 ]
then
	echo "Had a problem with the conversion:"
	cat $err_file
	sleep 3
	rm -f $out_file $err_file
	exit 1
fi

# Show the PostScript file
$GSPATH/gs $out_file 2>$err_file
if [ $? -ne 0 ]
then
	echo "Ghostscript didn't work!"
	cat $err_file
	read
# 	sleep 2
	exit 1
fi

# Clean up
rm -f $out_file $err_file
exit 0
