Note
[llpp.git] / misc / llpphtml
blobf3be070a4616728027af37bb41ed005f7e77bc09
1 #!/bin/sh
2 set -e
4 die() { echo "$1" >&2; exit 1; }
6 cachedir="${XDG_CACHE_HOME:-$HOME/.cache}/llpp"
7 test -d "$cachedir" || die "cache directory '$cachedir' does not exist"
9 command -v prince >/dev/null 2>&1 || { die "$0: need princeXML to work"; }
11 css=$HOME/xsrc/llpp/misc/prince.css
12 test -e "$css" || unset css
13 while getopts c:f opt; do
14 case $opt in
15 c) css="$OPTARG";;
16 f) force=true;;
17 ?) die "usage: $0 [-c css] url";;
18 esac
19 done
20 shift $(($OPTIND - 1))
21 test -z "$1" && die "usage $0: url"
23 url="$1"
24 set -- $(echo "$url" | md5sum)
25 pdf="$cachedir/$1.pdf"
27 ${force-$(test ! -e "$pdf")} && prince ${css:+--style $css} -o "$pdf" "$url"
28 exec llpp -origin "$url" "$pdf"