forked from pool/sane-backends
62 lines
1.7 KiB
Bash
62 lines
1.7 KiB
Bash
#! /bin/bash
|
|
#
|
|
# Johannes Meixner <jsmeix@suse.de>, 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 '<?xml version="1.0" encoding="ISO-8859-1"?>'
|
|
echo '<deviceinfo version="0.2">'
|
|
echo ' <device>'
|
|
echo
|
|
|
|
# Output generic SCSI scanner entry for those SCSI scanners which show up with scsi.type = scanner:
|
|
echo ' <match key="info.category" string="scsi_generic">'
|
|
echo ' <match key="@info.parent:scsi.type" string="scanner">'
|
|
echo ' <append key="info.capabilities" type="strlist">scanner</append>'
|
|
echo ' </match>'
|
|
echo ' </match>'
|
|
echo
|
|
|
|
# Output model specific USB scanner entries:
|
|
exec <$TMP_DATA
|
|
while read VENDOR PRODUCT
|
|
do echo ' <match key="info.bus" string="usb_device">'
|
|
echo " <match key=\"usb_device.vendor_id\" int=\"0x$VENDOR\">"
|
|
echo " <match key=\"usb_device.product_id\" int=\"0x$PRODUCT\">"
|
|
echo ' <append key="info.capabilities" type="strlist">scanner</append>'
|
|
echo ' </match>'
|
|
echo ' </match>'
|
|
echo ' </match>'
|
|
echo
|
|
done
|
|
|
|
# Output footer:
|
|
echo ' </device>'
|
|
echo '</deviceinfo>'
|
|
|
|
# Remove the temporary file
|
|
rm $TMP_DATA
|
|
|
|
exit 0
|
|
|