Update.
authorFrancois Fleuret <francois@fleuret.org>
Sun, 21 Aug 2016 19:25:32 +0000 (21:25 +0200)
committerFrancois Fleuret <francois@fleuret.org>
Sun, 21 Aug 2016 19:25:32 +0000 (21:25 +0200)
bashrc

diff --git a/bashrc b/bashrc
index dd9bc90..5e8a846 100644 (file)
--- 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}