diff --git a/README.md b/README.md index ddc17ec..e8155fe 100644 --- a/README.md +++ b/README.md @@ -88,10 +88,24 @@ OUTPUT -l, --outputlist 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 diff --git a/scan b/scan index 4572c05..3d6fd2c 100755 --- a/scan +++ b/scan @@ -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 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