Comment 393 for bug 85488

Revision history for this message
quazgar (quazgar) wrote : Enhancement to Joel Berger's script

Joel Berger gave a nice little wrapper script in comment #45. For some people this worked, for some people (like me, Canoscan lide 25, Feisty) the scanning element would not always return to its starting position. Until this is fixed, I'll post a new version of his script which basically changes the command to really reset/wake up the scanner again. IMHO this workaround point out that maybe the problem could be with sane, and not with libusb or the kernel. Anyway, here it is:

#!/bin/bash
# plustek-wrapper: finds a plustek USB device and keeps it alive while the
# wrapped program is running.
# Joel Berger <hikari (at) yumemiru (dot) org> 2007-04-15

# Requires:
# sane-utils (scanimage)
# sed
# gawk

# Detect device and store as $SANE_DEVICE
SANE_DEVICE=$( scanimage -L | \
                grep plustek | \
                sed 's/^.*plustek/plustek/' | \
                sed "s/' is a.*//" | \
                awk -F : '{print "/dev/bus/usb/" $3 "/" $4}'
             )

if [ $SANE_DEVICE ] ; then
  $* &
  CHILD_PID=$!
  while ps -p $CHILD_PID > /dev/null; do
# cat $SANE_DEVICE > /dev/null

# I'm not sure whether "scanimage -n" or
# "scanimage -L" is better here
      scanimage -n > /dev/null
      sleep 0.7
  done
else
  # If no plustek device is detected, bail out and run the program normally.
  exec $*
fi