Cleanup and document defaults and pre-scan hook

This commit is contained in:
Raman Gupta 2021-10-22 01:58:46 -04:00
parent c774b8eeca
commit 5bb8cd9ea1
2 changed files with 26 additions and 3 deletions

View File

@ -88,10 +88,24 @@ OUTPUT
-l, --outputlist <outputfile-1...outputfile-n> Output to named files for each scanned page, can be used with append
```
### Configuration
Use `--help` locally to show the location of optional configuration and
pre-scan hook scripts. These scripts may contain environment variables to
pre-configure `scan`. For example the contents of the `default` file may be
something like:
```
DEVICE=something
SEARCHABLE=1
MODE_HW_DEFAULT=1
```
### Tips
The default scanner device is set to `fujitsu`. If you have another scanner,
you will need to use the `-x`/`--device` argument to specify your scanner.
you will need to use the `-x`/`--device` argument to specify your scanner,
or save a `DEVICE=something` line to a local config file as shown above.
See below for how to get the list of available devices.
The scanners and scanner drivers vary in features they support. This script

13
scan
View File

@ -40,7 +40,9 @@ cleanup()
}
trap cleanup EXIT
[ -e "${XDG_DATA_HOME:-$HOME/.local/share}/sane-scan-pdf/defaults" ] && . "${XDG_DATA_HOME:-$HOME/.local/share}/sane-scan-pdf/defaults"
DEFAULTS="${XDG_DATA_HOME:-$HOME/.local/share}/sane-scan-pdf/defaults"
SCANPRE="${XDG_DATA_HOME:-$HOME/.local/share}/sane-scan-pdf/scan_pre"
[ -e "$DEFAULTS" ] && . "$DEFAULTS"
# Parse command-line options
while [[ $# > 0 ]]; do
@ -149,6 +151,13 @@ if [[ $HELP == 1 ]]; then
echo " Output to named file default=scan.pdf"
echo " -l, --outputlist <outputfile-1...outputfile-n> Output to named files for each scanned page, can be used with append"
echo ""
echo "CONFIGURATION"
echo "Local configuration can be written in the form of environment variables to:"
echo " $DEFAULTS"
echo ""
echo "A pre-scan hook script can be written to:"
echo " $SCANPRE"
echo ""
exit 0
fi
@ -272,7 +281,7 @@ if [[ $MODE_HW_DEFAULT == 1 ]]; then
else
MODE="--mode '$MODE'"
fi
[ -e "${XDG_DATA_HOME:-$HOME/.local/share}/sane-scan-pdf/scan_pre" ] && . "${XDG_DATA_HOME:-$HOME/.local/share}/sane-scan-pdf/scan_pre"
[ -e "$SCANPRE" ] && . "$SCANPRE"
eval scanadf -d \'"$DEVICE"\' $MAXPAGE $PGHEIGHT $PGWIDTH -S $SCRIPT --script-wait $DESKEW $CROP $DRIVER_OPTION $SOURCE --resolution $RESOLUTION $MODE -o $TMP_DIR/scan-%04d
# Simulate empty page scanner outputs for debugging
#convert xc:none -page Letter $TMP_DIR/scan-0001.pdf