mirror of
https://codeberg.org/leana8959/.files.git
synced 2026-02-01 22:49:41 +00:00
packages/easyscan: allow overriding easyscan options
This commit is contained in:
parent
25df5b3993
commit
5c311bbfdb
1 changed files with 42 additions and 6 deletions
48
nix/packages/by-name/easyscan/easyscan.sh
Normal file → Executable file
48
nix/packages/by-name/easyscan/easyscan.sh
Normal file → Executable file
|
|
@ -1,11 +1,51 @@
|
|||
#!/usr/bin/env bash
|
||||
# This is here because scanimage's batch mode is broken for my scanner
|
||||
|
||||
OUTPUT_FILE="${1:-./scan_"$(date)".pdf}"
|
||||
function help() {
|
||||
cat <<EOF
|
||||
easyscan
|
||||
|
||||
easyscan wraps scanimage and joins the resulting pdf.
|
||||
|
||||
Usage:
|
||||
easyscan <target_file> [ -- args ]:
|
||||
Scan a (multi-page) document to <target_file>, passing args to scanimage
|
||||
EOF
|
||||
}
|
||||
|
||||
if [ $# -lt 1 ]; then
|
||||
help
|
||||
exit 1
|
||||
fi
|
||||
OUTPUT_FILE="$1.pdf"
|
||||
if [ -e "$OUTPUT_FILE" ]; then
|
||||
echo "$OUTPUT_FILE" already exists, you are probably making a mistake!
|
||||
exit 1
|
||||
fi
|
||||
shift
|
||||
|
||||
scanimage_args=(
|
||||
"-x" "210"
|
||||
"-y" "297"
|
||||
"--resolution" "300"
|
||||
)
|
||||
|
||||
while [ $# -gt 0 ]; do
|
||||
case $1 in
|
||||
--help)
|
||||
help
|
||||
exit
|
||||
;;
|
||||
--)
|
||||
shift
|
||||
scanimage_args+=("$@")
|
||||
break
|
||||
;;
|
||||
*)
|
||||
shift
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
tempdir="$(mktemp -d)"
|
||||
filenames=()
|
||||
|
|
@ -26,11 +66,7 @@ while :; do
|
|||
|
||||
# If no size is set, the output will be wonky-sized
|
||||
# 210,297 is the size of A4
|
||||
scanimage -x 210 -y 297 --resolution 300 -o "$CUR_FNAME" >/dev/null 2>&1 ||
|
||||
{
|
||||
echo "Failed to scan page..."
|
||||
ok="false"
|
||||
}
|
||||
scanimage "${scanimage_args[@]}" -o "$CUR_FNAME" || ok="false"
|
||||
|
||||
if $ok; then
|
||||
counter=$((counter += 1))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue