Created
March 8, 2022 14:57
-
-
Save sidusnare/2d987d83c86f5575fe59200fef68ce38 to your computer and use it in GitHub Desktop.
Parses SANE's list of scanner support for completely supported scanners and lets you choose which scanner interface to show
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
for p in lynx grep sed cut;do | |
if ! command -v "${p}" >> /dev/null 2>> /dev/null ;then | |
echo "Please install ${p}" >&2 | |
exit 1 | |
fi | |
done | |
interface="Ethernet" | |
INTERFACES=( 'USB' 'IEEE-1394' 'SCSI' 'Parport' 'WiFi' 'Ethernet' 'RS232C' ) | |
HELP="Usage\n ${0} -i <interface> -h\n\t-i\tInterface to search for, must be one of ${INTERFACES[*]}\n\t-h\tPrint this handy message." | |
while getopts i:h modes; do | |
case "${modes}" in | |
i) | |
interface="${OPTARG}" | |
;; | |
h) | |
echo -e "${HELP}" | |
exit 0 | |
;; | |
*) | |
echo -e "Unknown option ${modes}\n${HELP}" >&2 | |
esac | |
done | |
canarry=0 | |
for int in "${INTERFACES[@]}";do | |
if [ "${int}" == "${interface}" ]; then | |
canarry=1 | |
fi | |
done | |
if [ "${canarry}" == 0 ]; then | |
echo "${interface} is not a valid interface, please choose one of ${INTERFACES[*]}" >&2 | |
exit 1 | |
fi | |
while read -r line;do | |
first="$( cut -d' ' -f 1 <<< "${line}" )" | |
if [ "${first}" == 'Manufacturer:' ]; then | |
#MFG="$( sed -e 's/Manufacturer://' <<< "${line}" )" | |
MFG="${line//Manufacturer: /}" | |
#echo "New Manufacturer: ${MFG}" | |
continue | |
fi | |
echo "${MFG} ${line}" | |
done < <( lynx -nolist -width=10240 -dump http://www.sane-project.org/sane-mfgs.html | grep -E 'Manufacturer:|Complete' | grep -E "Manufacturer:|${interface}" | sed -e "s/\t/ /g" -e 's/ */ /g' -e 's/^ //' ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment