packages/easyscan: remove temporary pdffiles

This commit is contained in:
Primrose 2025-07-14 14:48:09 +02:00
parent b8df1a2d33
commit adc40a83c4
Signed by: primrose
GPG key ID: 4E887A4CA9714ADA

View file

@ -1,18 +1,47 @@
if [ $# -eq 0 ]; then
#
# Declare variables
#
DEVICE="${SANE_DEFAULT_DEVICE:-}"
OUTPUT_FILE=
while [[ $# -gt 0 ]]; do
case $1 in
-d | --device)
# Allows user to override the device used, since scanimage is
# slow and the printer might not even change between runs
DEVICE="$2"
shift
shift
;;
-*)
echo "Unknown option $1"
exit 1
;;
*)
OUTPUT_FILE="$1"
shift
;;
esac
done
#
# Handle defaults
#
if [ -z "$OUTPUT_FILE" ]; then
OUTPUT_FILE=./scan_"$(date)".pdf
else
OUTPUT_FILE="''${1%.*}.pdf"
fi
if [ -z "$DEVICE" ]; then
DEVICE=$(scanimage --formatted-device-list="%d (%v %m)" --list-devices |
fzf --header "Pick a device:" |
cut -d ' ' -f 1)
fi
tempdir="$(mktemp -d)"
device=$(scanimage --formatted-device-list="%d (%v %m)" --list-devices |
fzf --header "Pick a device:" |
cut -d ' ' -f 1)
do_scan() {
filename="$tempdir/$(date).pdf"
while ! scanimage --format=pdf --device="$device" --resolution 300 >"$filename"; do
while ! scanimage --format=pdf --device="$DEVICE" --resolution 300 >"$filename"; do
:
done
echo "$filename"