33 lines
1.0 KiB
Bash
Executable File
33 lines
1.0 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
STORAGE_DIR="$HOME/.local/share/sevenkeys/scanimages/"
|
|
mkdir -p "$STORAGE_DIR"
|
|
|
|
ADD_CARDS=0
|
|
echo "scantap: Beginning scan loop"
|
|
while true; do
|
|
rng="$(cat /dev/random | tr -cd 'a-f0-9' | head -c 32)"
|
|
filename="$STORAGE_DIR/$rng.png"
|
|
|
|
scanimage --output-file="$filename" --source "ADF Front" --mode Color --page-width 63mm --page-height 88mm 2>/dev/null
|
|
|
|
# scanimage exits with code 7 if no documents are available in scanner
|
|
if test $? -eq 7; then
|
|
if test $ADD_CARDS -eq 0; then
|
|
ADD_CARDS=1
|
|
echo "scantap: No more cards in feeder" >&2
|
|
fi
|
|
|
|
continue
|
|
fi
|
|
ADD_CARDS=0
|
|
|
|
convert -rotate 180 "$filename" "$filename"
|
|
|
|
# TODO: Add "store" command to sevenkeys executable to avoid duplicating insert logic here, then `./sevenkeys --profile=production store --id="0000..0000"`
|
|
# Return inserted CardLocationId
|
|
#cardLocationId="1"
|
|
#mysql --silent --silent --user=root --password="$(pass show sevenkeys/mysql \
|
|
#-e "USE sevenkeys; INSERT INTO CardScan (CardLocationId, Filename) VALUES ('$cardLocationId', '$filename.png');"
|
|
done
|