LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 12-28-2010, 07:19 AM   #1
Xeratul
Senior Member
 
Registered: Jun 2006
Location: UNIX
Distribution: FreeBSD
Posts: 2,658

Rep: Reputation: 255Reputation: 255Reputation: 255
How to detect that an user has press the Scan button on an Epson Scanner?


It seems that they are not shown under xev ...

Someone knows if old scanner, can be detected in terms of button pressing ?

I tried this http://www.linux.com/archive/feed/59138


my button pressing does not show up into deamon.log

Last edited by Xeratul; 12-28-2010 at 07:21 AM.
 
Old 12-28-2010, 07:51 AM   #2
Xeratul
Senior Member
 
Registered: Jun 2006
Location: UNIX
Distribution: FreeBSD
Posts: 2,658

Original Poster
Rep: Reputation: 255Reputation: 255Reputation: 255
Ok, google is your friend like always, I found the scripts and installation procedure for debian on linux boards, as follows:

#1
apt-get install scanbuttond

#2
scanbuttond -f

#3 have this into: /etc/scanbuttond/buttonpressed.sh

Code:
#!/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"
		DEV="$2"
		mkdir -p /home/scanner/autoscans

			DATENOW=`date +%F[%HH%MM%S]`
			FILENAMEOUT="/home/scanner/autoscans/${DATENOW}_autoscanning.jpg"		
			if [ -f "$FILENAMEOUT" ] ;  then 
				FILENAMEOUT="/home/scanner/autoscans/${DATENOW}_autoscanning_02.jpg"
			fi
					
			if [ -f "$FILENAMEOUT" ] ;  then 
				FILENAMEOUT="/home/scanner/autoscans/${DATENOW}_autoscanning_03.jpg"
			fi
			echo " Scanning into $FILENAMEOUT. please wait ... "
			scanimage -d "$DEV" --resolution 300 --mode color  > tmp.ppm ; convert -rotate 180 tmp.ppm $FILENAMEOUT 


		if [ ! -f "$FILENAMEOUT" ] ; then
			scanimage -d "$DEV" --resolution 300 --mode color  > tmp.ppm ; convert -rotate 180 tmp.ppm $FILENAMEOUT 
		fi
		if [ ! -f "$FILENAMEOUT" ] ; then	
			scanimage -d "$DEV" --resolution 300 --mode color  > tmp.ppm ; convert -rotate 180 tmp.ppm $FILENAMEOUT 
		fi
		if [ ! -f "$FILENAMEOUT" ] ; then	
			scanimage -d "$DEV" --resolution 300 --mode color  > tmp.ppm ; convert -rotate 180 tmp.ppm $FILENAMEOUT 
		fi

			chmod ug+rwx -R /home/scanner/autoscans/

		;;
esac

Last edited by Xeratul; 12-28-2010 at 07:54 AM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
how do i scan a character from keyboard without the user having to press enter rasika Programming 6 02-11-2010 08:54 PM
Scanner Epson v100 can not work on normal user account ff1 Ubuntu 1 12-04-2008 03:48 PM
How to detect how many bytes of scan-code are coming for a key press? sridhar_ub Programming 4 03-25-2008 06:32 AM
How to detect how many bytes of scan-code are coming for a key press? sridhar_ub Linux - Newbie 3 03-24-2008 12:39 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 04:12 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration