Improve scan2paperless script
This commit is contained in:
parent
7b024bba84
commit
0c67eaefb5
|
@ -2,16 +2,28 @@ self:
|
||||||
with self; ''
|
with self; ''
|
||||||
export PATH=${lib.makeBinPath [pkgs.coreutils pkgs.sane-frontends pkgs.sane-backends pkgs.ghostscript pkgs.imagemagick]}
|
export PATH=${lib.makeBinPath [pkgs.coreutils pkgs.sane-frontends pkgs.sane-backends pkgs.ghostscript pkgs.imagemagick]}
|
||||||
|
|
||||||
while true;
|
NAME=$([ "$1" == "" ] && date -Iseconds || echo "$1")
|
||||||
do
|
|
||||||
read -p "Press Enter to continue or Ctrl+C to stop" < /dev/tty
|
|
||||||
|
|
||||||
|
TMPDIR=$(mktemp -d)
|
||||||
|
|
||||||
|
echo "Using ''${NAME}.pdf as filename"
|
||||||
|
RESPONSE=""
|
||||||
|
|
||||||
|
while [ -z "$RESPONSE" ];
|
||||||
|
do
|
||||||
DATETIME=$(date -Iseconds)
|
DATETIME=$(date -Iseconds)
|
||||||
|
echo "Starting scan $DATETIME"
|
||||||
scanimage \
|
scanimage \
|
||||||
-d "''${SCANNER_DEFAULT_DEVICE}" \
|
-d "''${SCANNER_DEFAULT_DEVICE}" \
|
||||||
--format=jpeg \
|
--format=jpeg \
|
||||||
--resolution 300 \
|
--resolution 300 \
|
||||||
--progress \
|
--progress \
|
||||||
-o "''${SCANNER_OUTPUT_DIR}/''${DATETIME}.jpg"
|
-o "''${TMPDIR}/''${DATETIME}.jpg"
|
||||||
|
|
||||||
|
read -p "Press ENTER to scan another page, or any other key to generate the final PDF: " RESPONSE < /dev/tty
|
||||||
done
|
done
|
||||||
|
|
||||||
|
${python39Packages.img2pdf}/bin/img2pdf --output "''${SCANNER_OUTPUT_DIR}/''${NAME}.pdf" ''${TMPDIR}/*
|
||||||
|
|
||||||
|
rm -rf TMPDIR
|
||||||
''
|
''
|
||||||
|
|
Loading…
Reference in a new issue