mirror of
https://codeberg.org/leana8959/.files.git
synced 2025-12-06 22:59:15 +00:00
packages/easyscan: remove temporary pdffiles
This commit is contained in:
parent
b8df1a2d33
commit
adc40a83c4
1 changed files with 37 additions and 8 deletions
|
|
@ -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"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue