5 CACHEDIR
=$HOME/.config
/llpp
14 command -v $1 >/dev
/null
2>&1
17 trap '! test -z $casp && rm -f $casp' 0
19 test -d $CACHEDIR || die
"cache directory $CACHEDIR does not exist"
20 while getopts m
: opt
; do
24 die
"usage: $0 [-t mime/type] path";
28 shift $
(($OPTIND - 1))
29 test -z "$1" && die
"usage $0: path"
31 ft
=$
(file --mime-type -b "$1")
34 application
/x-gzip
) dc=zcat
;;
35 application
/x-xz
) dc=xzcat
;;
36 application
/x-bzip2
) dc=bzcat
;;
40 test -z $dc || ft
=$
(file --mime-type -bz "$1")
42 filt
='${dc-cat} "$1" |'
46 application
/postscript
) conv
='ps2pdf - $casp';;
47 application
/pdf
) test -z $dc && exec llpp
"$1" || conv
='cat >$casp';;
48 image
/vnd.djvu
) conv
='djvups - | ps2pdf - $casp';;
50 if executable_p unoconv
&& test -z $dc; then
52 conv
='unoconv -o $casp "$1"'
54 conv
='antiword -m 8859-1.txt -a a4 - >$casp'
57 application
/vnd.openxmlformats-officedocument.
*) {
58 if executable_p unoconv
; then
59 ! test -z $dc && die
"can not convert compressed $mime"
61 conv
='unoconv -o $casp "$1"'
63 die
'unoconv not found'
67 executable_p rsvg-convert \
68 && conv
='rsvg-convert -f pdf -o $casp' \
69 || conv
='inkscape -z -A $casp -'
71 image
/*) conv
='convert - pdf:$casp';;
73 test -z $dc || die
"can not handle compressed DVIs"
75 conv
='dvipdf $1 $casp'
77 *) die
"unhandled file type: $mime";;
80 hash=$
(md5sum "$1" | cut
-f 1 -d\
)
81 casp
="$CACHEDIR/$hash"
82 test -e $casp ||
eval "$filt" "$conv"
86 exec llpp
-origin "$origin" $casp "$@"