Remove stray spaces
[llpp.git] / misc / llpphtml
blob76a412ad5f9a3704a6f44d09007654f6105b2ccb
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 || {
10 die "$0: prince(https://www.princexml.com/) not found"
13 css=$HOME/xsrc/llpp/misc/prince.css
14 test -e "$css" || unset css
15 while getopts c:f opt; do
16 case $opt in
17 c) css="$OPTARG";;
18 f) force=true;;
19 ?) die "usage: $0 [-c css] url";;
20 esac
21 done
22 shift $(($OPTIND - 1))
23 test -z "$1" && die "usage $0: url"
25 url="$1"
26 set -- $(echo "$url" | cksum)
27 pdf="$cachedir/$1.pdf"
29 ${force-$(test ! -e "$pdf")} && prince ${css:+--style $css} -o "$pdf" "$url"
30 exec llpp -layout-height 0 -origin "$url" "$pdf"