1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83
|
#!/bin/sh
# This script is started by scanbuttond whenever a scanner button has been pressed.
# Scanbuttond passes the following parameters to us:
# $1 ... the button number
# $2 ... the scanner's SANE device name, which comes in handy if there are two or
# more scanners. In this case we can pass the device name to SANE programs
# like scanimage.
# *** WARNING ***
# The example code below contains just simple examples how things may get done.
# Don't simply uncomment the code on systems with untrusted users! This would
# make your button scanning vulnerable to various kinds of attacks by local users.
# *** WARNING ***
TMPFILE="/tmp/scan.tiff"
LOCKFILE="/tmp/copy.lock"
case $1 in
1)
echo "button 1 has been pressed on $2"
# This example turns your scanner+printer into a photocopier.
# Fine-tuned for the Epson Perfection 2400, the HP LaserJet 1200 and
# ISO A4 paper size so that the scanned document matches the printer
# output as closely as possible.
# The festival speech synthesizer is used to inform the user about
# the progress of the operation.
#
#
# if [ -f $LOCKFILE ]; then
# echo "Error: Another scanning operation is currently in progress" | festival --tts
# exit
# fi
# touch $LOCKFILE
# rm -f $TMPFILE
# echo "Copying" | festival --tts
# scanimage --device-name $2 --format tiff --mode Gray --quick-format A4 \
# --resolution 300 --sharpness 0 --brightness -3 \
# --gamma-correction "High contrast printing" > $TMPFILE
# if [ $? != 0 ]; then
# echo "Scanning failed" | festival --tts
# rm $LOCKFILE
# exit
# fi
# echo "Submitting print job" | festival --tts
# tiff2ps -z -w 8.27 -h 11.69 $TMPFILE | lpr
# if [ $? != 0 ]; then
# echo "Printing failed" | festival --tts
# rm $LOCKFILE
# exit
# fi
# echo "The print job has been submitted" | festival --tts
# rm -f $LOCKFILE
#
# Another example of the same action, but using other tools and
# working with newer scanimage versions.
# It requires sane-utils, lockfile-progs and netpbm.
# Suggested by Francesco Potorti`.
#
# if ! lockfile-create --retry 2 $LOCKFILE; then
# echo "Error: scanning already in progress for $2"
# exit
# fi
# SCAN_OPTIONS="--resolution 300 --contrast 10 --brightness 0"
# scanimage --verbose --device-name $2 \
# --mode Gray -x 210 -y 297 $SCAN_OPTIONS |
# pnmtops -width=8.27 -height=11.69 |
# lpr -J $2 $PRINTER
# lockfile-remove $LOCKFILE
;;
2)
echo "button 2 has been pressed on $2"
;;
3)
echo "button 3 has been pressed on $2"
;;
4)
echo "button 4 has been pressed on $2"
;;
esac
|