From: Francois Fleuret <francois@fleuret.org>
Date: Sun, 21 Aug 2016 19:25:32 +0000 (+0200)
Subject: Update.
X-Git-Url: https://fleuret.org/cgi-bin/gitweb/gitweb.cgi?a=commitdiff_plain;h=ffbc2bb60d0053e05a4da7874e7ee2cf4208c25e;p=scripts.git

Update.
---

diff --git a/bashrc b/bashrc
index dd9bc90..5e8a846 100644
--- a/bashrc
+++ b/bashrc
@@ -251,6 +251,40 @@ function bak () {
     done
 }
 
+function scan () {
+    n=1
+
+    while [[ -f "${HOME}/scan-${n}.jpg" ]]; do
+        n=$((n+1))
+    done
+
+    while [[ "$1" ]]; do
+        if [[ "$1" == "color" ]]; then
+            OPTS+=" --mode=color"
+        elif [[ "$1" == "a4crop" ]]; then
+            OPTS+=" -l 5 -t 0 -x 200 -y 290"
+        else
+            echo "Unknown argument \`$1'"
+        fi
+        shift
+    done
+
+    echo "**"
+    echo "** Scanning to ${HOME}/scan-${n}.jpg"
+    echo "**"
+
+    scanimage -d genesys:libusb:001:056 \
+              --format=pnm \
+              --mode=color \
+              --depth=8 \
+              -v \
+              --resolution=300 \
+              ${OPTS} | \
+        convert -rotate 180 - "${HOME}/scan-${n}.jpg"
+
+    echo "** Done".
+}
+
 # A password generator
 
 function genpw () {
@@ -338,7 +372,7 @@ alias t='cd /tmp'
 alias a='cd /tmp/at'
 
 function trash () {
-    TRASH=$(date +/tmp/trash-%Y-%b-%d-%Hh)
+    TRASH=$(date +/tmp/trash-${USER}-%Y-%b-%d-%Hh)
     LINK=/tmp/trash
 
     mkdir -p ${TRASH}