diff options
author | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2014-10-06 14:00:40 +0200 |
---|---|---|
committer | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2014-10-06 14:00:40 +0200 |
commit | 6e9c41a892ed0e0da326e0278b3221ce3f5713b8 (patch) | |
tree | 2e301d871bbeeb44aa57ff9cc070fcf3be484487 /tools/hotplug-ng |
Initial import of sane-backends version 1.0.24-1.2
Diffstat (limited to 'tools/hotplug-ng')
-rw-r--r-- | tools/hotplug-ng/README | 46 | ||||
-rwxr-xr-x | tools/hotplug-ng/libsane.hotplug | 29 |
2 files changed, 75 insertions, 0 deletions
diff --git a/tools/hotplug-ng/README b/tools/hotplug-ng/README new file mode 100644 index 0000000..1a17a19 --- /dev/null +++ b/tools/hotplug-ng/README @@ -0,0 +1,46 @@ +hotplug/hotplug-ng hook for sane-backends +----------------------------------------- + +The libsane.hotplug script is intended to replace the existing hotplug scripts, +as those won't be usable with the new hotplug-ng. The libsane.hotplug script +works with both hotplug and hotplug-ng. For current Linux kernels, "udev" is +state of the art, see the "udev" directory instead. + +This script is provided in the hope that it will be useful, simpler, faster and +more extensible than the current usermap approach. + + +INSTALLATION +------------ + +Install libsane.hotplug in /etc/hotplug/usb, and make it executable. + +Create the directory /etc/sane.d/hotplug and copy libsane.db there. + + +FILE FORMAT +----------- + +The libsane.db contains 5 tab-separated fields: + +0xVVVV<tab>0xPPPP<tab>root:scanner<tab>0660<tab>optional_script + +Fields: + - vendor ID + - product ID + - ownership (user:group) + - permissions + - path of an optional script to run (it can be omitted) + + +USAGE +----- + +When run by hotplug/hotplug-ng, the libsane.hotplug script will grep for +^0xVVVV[[:space:]]0xPPPP in /etc/sane.d/hotplug/*.db. If a match is found, +the settings are applied to the device. + +The optional script is then run; this script can access the environment +variables set by hotplug/hotplug-ng (see the documentation). The libsane.hotplug +script will also set and export the DEVVID and DEVPID variables, containing the +vendor and device ID of the scanner (of the form VVVV and PPPP). diff --git a/tools/hotplug-ng/libsane.hotplug b/tools/hotplug-ng/libsane.hotplug new file mode 100755 index 0000000..dec38a5 --- /dev/null +++ b/tools/hotplug-ng/libsane.hotplug @@ -0,0 +1,29 @@ +#!/bin/sh +# +# This file is part of the SANE distribution. +# Hotplug USB hook for SANE + +if [ "$ACTION" != "add" ]; then + exit 0 +fi + +DEVVID=$(printf %4s $(echo $PRODUCT | cut -d'/' -f1) | tr ' ' 0) +DEVPID=$(printf %4s $(echo $PRODUCT | cut -d'/' -f2) | tr ' ' 0) + +DEVCONF=$(grep -i "^0x$DEVVID[[:space:]]\+0x$DEVPID" /etc/sane.d/hotplug/*.db 2> /dev/null) + +if [ $? != 0 ]; then + exit 0 +fi + +set $DEVCONF + +chown $3 $DEVICE && chmod $4 $DEVICE + +if [ ! -z $5 -a -x $5 ]; then + export DEVVID + export DEVPID + exec $5 +fi + +exit 0 |