Actions are located in /usr/local/etc/scanbd/scanbd.conf
.
I have 4 buttons that are scan, copy, email and file.
The default config file doesn't include all actions per default, you will probably have to add the block manually. You can have less or more buttons depending of your scanner model.
For each action, we will set a custom path for the script option.
action scan {
filter = "^scan.*"
numerical-trigger {
from-value = 1
to-value = 0
}
desc = "Scan to file"
# script must be an relative path starting from scriptdir (see above),
# or an absolute pathname.
# It must contain the path to the action script without arguments
# Absolute path example: script = "/some/path/foo.script
script = "/home/pi/scan.sh"
}
Don't forget to comment any other default action at the end of scanbd.conf :
# devices
# each device can have actions and functions, you can disable not relevant devices
#include(scanner.d/avision.conf)
#include(scanner.d/fujitsu.conf)
#include(scanner.d/hp.conf)
#include(scanner.d/pixma.conf)
#include(scanner.d/snapscan.conf)
#include(scanner.d/canon.conf)
You can now create your custom script to handle each action :
Each line relative to
/sys/class/leds/led0/trigger
are for controlling the LED to monitor what's going on. You can do whatever you want,cat /sys/class/leds/led0/trigger
gives you all different pattern of lights.
/home/pi/scan.sh
#!/bin/bash
# don't forget to create the folder
scan_dir=/home/pi/scanned-files
datetime=`date +%F_%H%M%S`
echo none >/sys/class/leds/led0/trigger
case $SCANBD_ACTION in
scan)
filename=file-$datetime
logger -t "scanbd: $0" "$SCANBD_DEVICE $SCANBD_ACTION - scanning --resolution 150 --mode Color --depth 8 --format=tiff to $scan_dir/$filename.jpg"
echo timer >/sys/class/leds/led0/trigger
scanimage -d $SCANBD_DEVICE --resolution 150 --mode Color --depth 8 --format=tiff --brightness 5 --contrast 20 | convert tiff:- -compress jpeg $scan_dir/$filename.pdf
echo none >/sys/class/leds/led0/trigger
logger -t "scanbd: $0" "Finished scanning"
;;
email)
logger -t "scanbd: $0" "Emailing $scan_dir/file-*pdf"
echo heartbeat >/sys/class/leds/led0/trigger
# here are the lines to send the file
echo none >/sys/class/leds/led0/trigger
esac