#! /bin/bash # # Johannes Meixner , 2004, 2005, 2006 #set -x export PATH="/sbin:/usr/sbin:/usr/bin:/bin" export LC_ALL="POSIX" export LANG="POSIX" umask 022 MY_NAME=${0##*/} # Input: # Create temporary files: TMP_DATA=$(mktemp -u /tmp/$MY_NAME.XXXXXX) # Extract USB entries from the libsane.rules file: test -n "$1" && RULES_FILE="$1" || RULES_FILE="libsane.rules" ls $RULES_FILE &>/dev/null || { echo "$MY_NAME error: Required libsane.rules file $RULRS_FILE not found." 1>&2 ; exit 3 ; } sed -n -e 's/^SYSFS{idVendor}=="\([^"]*\)", SYSFS{idProduct}=="\([^"]*\)",.*/\1 \2/p' $RULES_FILE | tr '[:upper:]' '[:lower:]' | sort -u >$TMP_DATA # Output: # Output header: echo '' echo '' echo ' ' echo # Output generic SCSI scanner entry for those SCSI scanners which show up with scsi.type = scanner: echo ' ' echo ' ' echo ' scanner' echo ' ' echo ' ' echo # Output model specific USB scanner entries: exec <$TMP_DATA while read VENDOR PRODUCT do echo ' ' echo " " echo " " echo ' scanner' echo ' ' echo ' ' echo ' ' echo done # Output footer: echo ' ' echo '' # Remove the temporary file rm $TMP_DATA exit 0