From c89d3aae14ce3bcee6fbdddd89545a110d7798d0 Mon Sep 17 00:00:00 2001 From: prunebutt Date: Sun, 21 Sep 2025 21:51:54 +0200 Subject: [PATCH] initial commit --- scanbuddy.bash | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100755 scanbuddy.bash diff --git a/scanbuddy.bash b/scanbuddy.bash new file mode 100755 index 0000000..ca61674 --- /dev/null +++ b/scanbuddy.bash @@ -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 <