[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

rpms/scanbuttond/FC-6 buttonpressed.sh, 1.1, 1.2 scanbuttond.spec, 1.3, 1.4



Author: paragn

Update of /cvs/pkgs/rpms/scanbuttond/FC-6
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv1338

Modified Files:
	buttonpressed.sh scanbuttond.spec 
Log Message:
- Replaced buttonpressed.sh script version with Chris Bagwell's
  version given in RFE rh#234954.




Index: buttonpressed.sh
===================================================================
RCS file: /cvs/pkgs/rpms/scanbuttond/FC-6/buttonpressed.sh,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- buttonpressed.sh	16 Oct 2006 15:47:09 -0000	1.1
+++ buttonpressed.sh	4 May 2007 09:41:52 -0000	1.2
@@ -1,48 +1,102 @@
 #!/bin/sh
 
-# This script is started by scanbuttond whenever a scanner button has been pressed.
+# 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.
+# $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.
+#
+# No locking is performed because scanbuttond can not monitor button
+# pressing using libusb while sane is scanning.  It also doesn't appear
+# to scan for new button presses until this script exits.
+# 
 
-TMPFILE="/tmp/scan.tiff"
-LOCKFILE="/tmp/copy.lock"
+EDITBUTTON=1
+PRINTBUTTON=2
+EMAILBUTTON=3
+CUSTOMBUTTON=4
+
+if [ "$1"x = "$EDITBUTTON"x ] ; then
+  MODE=Color
+  RESOLUTION=300
+elif [ "$1"x = "$PRINTBUTTON"x ] ; then
+  MODE=Color
+  RESOLUTION=150
+elif [ "$1"x = "$EMAILBUTTON"x ] ; then 
+  MODE=Color
+  RESOLUTION=150
+else
+  MODE=Color
+  RESOLUTION=300
+fi
+
+TMPFILE="/tmp/scan.pnm"
+TMPJPGFILE="/tmp/scan.jpg"
+
+# 8.5 x 11
+SCANIMAGE_PAGESIZE="-x 215 -y 279"
+# A4
+#SCANIMAGE_PAGESIZE="-x 210 -y 297"
+
+scancmd() {
+    scanimage --device-name $2 --mode $MODE --resolution $RESOLUTION --depth 8 $SCANIMAGE_PAGESIZE > $TMPFILE
+}
+
+editcmd() {
+    gimp $TMPFILE
+}
+
+printcmd() {
+    lpr -o fitplot $TMPFILE
+}
+
+mailcmd() {
+    convert $TMPFILE -quality 85 -quiet $TMPJPGFILE
+    # FIXME: Evolution doesn't seem to put itself in the
+    # background after this command is issued; at least
+    # if its not already running.  This will cause this
+    # script to not exit.  If we just put this into the
+    # background then our cleanup() will delete the file
+    # before it can be used.
+    #evolution mailto:?attach=${TMPJPGFILE}
+    thunderbird -compose attachment="file://${TMPJPGFILE}"
+}
+
+# function: remove temporary files
+cleanup() {
+    rm -f $TMPFILE
+    if [ -e $TMPJPGFILE ] ; then
+        rm -f $TMPJPGFILE
+    fi
+}
 
 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.
-		#
-		# if [ -f $LOCKFILE ]; then
-		#   echo "Error: Another scanning operation is currently in progress"
-		#   exit
-		# fi
-		# touch $LOCKFILE
-		# rm -f $TMPFILE
-		 scanimage --device-name $2 -x 215 -y 297 1> /tmp/image.pnm
-		 gimp /tmp/image.pnm
-		# tiff2ps -z -w 8.27 -h 11.69 $TMPFILE | lpr
-		# rm -f $LOCKFILE
-		#
+	$EDITBUTTON)
+		echo "button $EDITBUTTON has been pressed on $2"
+
+                 scancmd $*
+                 editcmd
+                 cleanup 
 		;;
-	2)
-		echo "button 2 has been pressed on $2"
-                 scanimage --device-name $2 -x 215 -y 297 1> /tmp/image.pnm
-		 lpr /tmp/image.pnm	
+	$PRINTBUTTON)
+		echo "button $PRINTBUTTON has been pressed on $2"
+
+                 scancmd $*
+		 printcmd
+                 cleanup 
 		;;
-	3)
-		echo "button 3 has been pressed on $2"
-                 scanimage --device-name $2 -x 215 -y 297 1> /tmp/image.pnm
-	          evolution mailto:?attach=/tmp/image.pnm	
+	$EMAILBUTTON)
+		echo "button $EMAILBUTTON has been pressed on $2"
+
+                 scancmd $*
+                 mailcmd
+                 cleanup
 		;;
-	4)
-		echo "button 4 has been pressed on $2"
+	$CUSTOMBUTTON)
+		echo "button $CUSTOMBUTTON has been pressed on $2"
 		;;
 esac
 


Index: scanbuttond.spec
===================================================================
RCS file: /cvs/pkgs/rpms/scanbuttond/FC-6/scanbuttond.spec,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- scanbuttond.spec	17 Oct 2006 17:27:03 -0000	1.3
+++ scanbuttond.spec	4 May 2007 09:41:52 -0000	1.4
@@ -1,6 +1,6 @@
 Name:            scanbuttond
 Version:         0.2.3
-Release:         9%{?dist}
+Release:         10%{?dist}
 Summary:         Scanner Button tools to SANE
 
 Group:           System Environment/Libraries
@@ -77,6 +77,10 @@
 
 
 %changelog
+* Tue May 03 2007 Parag Nemade <panemade gmail com>- 0.2.3-10
+- Replaced buttonpressed.sh script version with Chris Bagwell's
+  version given in RFE rh#234954.
+
 * Mon Oct 16 2006 Parag Nemade <panemade gmail com>- 0.2.3-9
 - Got CVS tagging problem as usual to me
 - so increasing release number


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]