Retourner aux forums || Retourner au forum
Astuces.divers : [Debian] scanbuttond
Posté par mathieu mathieu (Jabber id, page perso, ) le 10 novembre 2007
0
Mon scanner est connecté à mon serveur et est accessible par sane.d. Mais le problème est que allumer un pc pour scanner vite fait un courier important, ou faire une photocopie est laborieux! Heureusement le démon scanbuttond est là .... Voici le script debian modifié permettant
- de photocopier
- d'envoyer par mail (économie de papier)
fichier /etc/scanbuttond/buttonpressed.sh
#!/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.
TMPFILE="/tmp/scan.tiff"
TMPFILEJPG="/tmp/scan-`date +%Y-%m-%d.%H:%M:%S`.jpg"
FILEJPG="scan-`date +%Y%m%d%H%M%S`.jpg"
LOCKFILE="/tmp/scancopy.lock"
DEVICENAME=$2
scanmail()
{
SCAN_OPTIONS="--resolution 300 --contrast 10 --brightness 0"
scanimage --verbose --device-name $DEVICENAME \
--mode Gray -x 210 -y 297 $SCAN_OPTIONS | \
pnmtojpeg --quality=90 > $TMPFILEJPG
uuencode $TMPFILEJPG $FILEJPG | mail -s "scan:$FILEJPG" $1
rm $TMPFILEJPG
}
scanprint()
{
SCAN_OPTIONS="--resolution 300 --contrast 10 --brightness 0"
scanimage --verbose --device-name $DEVICENAME \
--mode Gray -x 210 -y 297 $SCAN_OPTIONS | \
pnmtops -width=8.27 -height=11.69 | \
lpr -J $DEVICENAME $PRINTER
}
if ! lockfile-create --retry 2 $LOCKFILE; then
echo "Error: scanning already in progress for $2"
exit
fi
case $1 in
1)
beep
scanmail "titi@mail.com;
;;
2)
beep
scanprint;
;;
3)
beep
scanmail "toto@mail.com";
;;
esac
lockfile-remove $LOCKFILE
> Lire le message (0 commentaire).
Revenir en haut de page || Retourner aux forums || Retourner au forum


Cette discussion est archivée, il n'est plus possible de laisser des commentaires.
Note : les commentaires appartiennent à ceux qui les ont postés. Nous n'en sommes pas responsables.