initial commit
This commit is contained in:
commit
c89d3aae14
1 changed files with 61 additions and 0 deletions
61
scanbuddy.bash
Executable file
61
scanbuddy.bash
Executable file
|
|
@ -0,0 +1,61 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
brother_opts=()
|
||||
scanner_mode='Black & White'
|
||||
resolution='300'
|
||||
source='Automatic Document Feeder(left aligned)'
|
||||
duplex_source='Automatic Document Feeder(left aligned,Duplex)'
|
||||
|
||||
device="brother5:bus4;dev3"
|
||||
|
||||
valid_resolutions=("100" "150" "200" "300" "400" "600" "1200")
|
||||
|
||||
current_page=$(find "$PWD" -name "out*.pdf" | sort | tail -n 1);
|
||||
read -r current_pageno <<<"${current_page//[^0-9]/ }"
|
||||
|
||||
current_pageno=${current_pageno:-0}
|
||||
|
||||
next_out_file="out$((current_pageno+1)).pdf"
|
||||
|
||||
scan() {
|
||||
while getopts "dr:" flag; do
|
||||
case ${flag} in
|
||||
d)
|
||||
echo "Scanning duplex"
|
||||
source=$duplex_source
|
||||
;;
|
||||
r)
|
||||
echo "Resolution=$OPTARG"
|
||||
if [[ ! " ${valid_resolutions[*]} " =~ [[:space:]]${OPTARG}[[:space:]] ]]; then
|
||||
echo "Resolution not supported"
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
b)
|
||||
echo "Black and white";
|
||||
;;
|
||||
*)
|
||||
;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
scan)
|
||||
scan "${@:2}"
|
||||
exit 0
|
||||
|
||||
if [ "$2" = "duplex" ]; then
|
||||
true
|
||||
fi
|
||||
|
||||
# cat <<EOF
|
||||
echo "Scanning to '$next_out_file'..."
|
||||
scanimage --device-name=$device --format=pdf --output-file="$next_out_file" \
|
||||
--mode="$scanner_mode" --resolution="$resolution" \
|
||||
--source="$source"
|
||||
;;
|
||||
*)
|
||||
echo "Usage: scanbuddy"
|
||||
;;
|
||||
esac
|
||||
Loading…
Add table
Add a link
Reference in a new issue