#! /bin/bash # # Johannes Meixner , 2004, 2005, 2006, 2007, 2008 # Till Kamppeter , 2008 #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) cat /dev/null >$TMP_DATA # Extract HPLIP USB ID classes (the digits in entries like SYSFS{idProduct}=="??12") # and generate all possible HPLIP USB device IDs, see # https://bugs.launchpad.net/bugs/195782 test -n "$1" && RULES_FILE="$1" || RULES_FILE="hpmud.rules" test -r $RULES_FILE || { echo "$MY_NAME error: Cannot read file '$RULES_FILE'." 1>&2 ; exit 3 ; } for CLASS in $( sed -n -e '/idVendor}=="03f0"/s/.*idProduct}=="??\([0-9A-Za-z]*\)".*/\1/p' $RULES_FILE ) do for A in 0 1 2 3 4 5 6 7 8 9 a b c d e f do for B in 0 1 2 3 4 5 6 7 8 9 a b c d e f do echo "0x$A$B$CLASS" >>$TMP_DATA done done done # Output: # Output header: echo '' echo '' echo ' ' # Output model specific HP USB device entries: exec <$TMP_DATA while read PRODUCT do echo echo ' ' echo ' ' echo -n ' ' echo ' scanner' echo ' ' echo ' ' echo ' ' done # Output footer: echo echo ' ' echo '' # Remove the temporary file rm $TMP_DATA exit 0