[sane-devel] Calling a script after USB scanner is plugged

Rainer Dorsch rdorsch at web.de
Tue Apr 22 20:18:39 UTC 2008


I want to call a script after I plugged my USB scanner. I use udev for this by 
adding a rule

rd at blackbox:/etc/udev/rules.d$ cat z_local.rules
SYSFS{idVendor}=="1606", SYSFS{idProduct}=="0010", MODE="0664", 
GROUP="scanner", NAME="umax%n", RUN+="/usr/local/bin/umax1220u start", 
rd at blackbox:/etc/udev/rules.d$

This calls then the umax1220u script:

rd at blackbox:/usr/local/bin$ cat umax1220u
set -vx
# example for a DEVICE: /proc/bus/usb/001/004

  echo umax1220u $DEVICE $* >> /tmp/usb.log
  export >> /tmp/usb.log

#  if [ -z $DEVICE ]; then exit 0; fi

  case $ACTION in
          echo "UMAX 1220u scanner added"
  #        DEV=umax1220u:libusb:`echo $DEVICE|cut -d / -f 5`:`echo $DEVICE|
cut -d / -f 6`
          DEV=`scanimage -L|cut -f 2 -d \\\`|cut -f1 -d \'`
          echo started: $DEV >> /tmp/usb.log
          # example for a DEV umax1220u:libusb:001:006
          (sleep 20 
&& /usr/bin/scanimage --lamp-off --device=$DEV --dont-scan) &
          echo "UMAX 1220u scanner removed"
rd at blackbox:/usr/local/bin$

When I plug my scanner with this config, it seems an infinite number of 
umax1220u scripts are started in a sequence (i.e. not in parallel, when one 
is completed the next one starts).

Initial analysis shows that scanimage causes in syslog

Apr 22 22:07:48 blackbox kernel: ppdev0: registered pardevice
Apr 22 22:07:48 blackbox kernel: ppdev0: unregistered pardevice
Apr 22 22:07:50 blackbox kernel: ppdev0: registered pardevice
Apr 22 22:07:50 blackbox kernel: ppdev0: unregistered pardevice

This might then kick off another umax1220u via udev (?). An this would then 

Does anybody know how I could get rid of this event?

Does anybody know a better way to get the script started which switches the 
scanner lamp off?


Rainer Dorsch
Lärchenstr. 6
D-72135 Dettenhausen
email: rdorsch at web.de
jabber: rdorsch at jabber.org
GPG Fingerprint: 5966 C54C 2B3C 42CC 1F4F  8F59 E3A8 C538 7519 141E
Full GPG key: http://pgp.mit.edu/

More information about the sane-devel mailing list