Rogue Class Linux Download Login

Artifact Content

Artifact 17298ff535e1611de5981c74bf15c6bf51c0f6a1:


#!/bin/sh
pdf="$1"
if [ ! -f "$pdf" ]
then
    echo "Usage: dpdf-open file.pdf"
    exit 1
fi

result=$(mktemp)
trap onexit EXIT
onexit()
{
    rm -f $result
}

size=$(du -b "$pdf" | cut -f 1)
limit=10000000
if [ $size -lt $limit ]
then
    rig ~/settings/history.cfg push $(tty) "dpdf \"$pdf\""
    exit 0
fi

message="That PDF is over 10,000,000 bytes large.  Depending on the content, a
low-end computer might run out of memory.  Choose an option."

dialog                                                      \
    --title "Very Large PDF"                                \
    --icons /usr/share/icons/gnome/48x48                    \
    --menu "$message" 0 0 5                                 \
    CANCEL "Cancel" actions/process-stop.png                \
    EXPORT "Export to DJVU" actions/document-revert-rtl.png \
    OPEN   "Open PDF anyway" actions/document-open.png      \
    2>$result
if [ $? -ne 0 ]
then
    exit 0
fi
case $(<$result) in
EXPORT)
    rig ~/settings/history.cfg push $(tty) "dpdf-export \"$pdf\""
    ;;
OPEN)
    rig ~/settings/history.cfg push $(tty) "dpdf \"$pdf\""
    ;;
esac
exit 0